Open derekr opened 1 year ago
Thank you for your suggestion! For the Annotation
component, adding it as part of the mapkit-react library is definitely the way to go (thank you very much for your PR!). Do you have other use cases in mind where an API change would be helpful?
The other thing I can think of is maybe custom map controls. Positioning isn't dependent coordinates, but you want access to the map instance to call methods.
function AnnotationsCount() {
const map = useMap()
return <div>{ map.annotations.length }</div>
}
<Map>
<AnnotationsCount />
</Map>
This alternative implementation here could give an idea how a useMap hook could look like: https://github.com/chrisdrackett/react-mapkit/blob/main/src/useMap.tsx
Would be cool to implement something similar in this library!
The other thing I can think of is maybe custom map controls. Positioning isn't dependent coordinates, but you want access to the map instance to call methods.
function AnnotationsCount() { const map = useMap() return <div>{ map.annotations.length }</div> } <Map> <AnnotationsCount /> </Map>
Hi @derekr,
I was thinking about how an implementation of this could look like and how to make it beneficial recently.
The problem with your example I came up with, is that it could be only used within the component as you already pointed out in your example, as there could be many components within a React application. So usually - looking at the storybook examples - it is supposed to render additional divs outside the component and not inside I suppose.
Also I was thinking about additional controls over the map which might be rendered outside the however, I don't really see a good way of how to give the context the information which component am I looking for.
Could you provide additional information about the expected usages and how to get benefits out of this implementation. I agree it could be very nice to have such a hook, however, I cannot yet think of a suitable implementation.
Hi everyone,
I'm wondering if anyone is currently working on this issue. I really need this feature and would be happy to help out if needed. Please let me know how I can help!
Hey @remib18 I don't think anyone is currently working on this feature, so you are very welcome to participate!
The last thing I personally was working on is the annotation clustering. I made some progress there already but got stuck and haven't yet have time to further investigate. Should be not anything related to this one.
Thank you @remib18 for your interest in the project! What is the use case you would need access to the map context for?
Thank you @remib18 for your interest in the project! What is the use case you would need access to the map context for?
Hey!
I'm updating an old codebase to React. Since I have already implemented geocoding and reverse geocoding using the native MapKit API, it would be practical to have access to the MapKit API within the map context. Moreover, I don't see any particular reason to hide the map context. However, I might be wrong, or there could be other ways to access it that I'm not aware of.
Thanks!
Hey! Digging the project so far! The API and code organization are great. Was wondering if exporting
MapContext
or auseMapContext
hook would be inline with the API you want to support. I'm trying to use refs per the storybook examples, but find it a little clunky and unreliable for certain use cases. Particularly I want to author anAnnotation
component for custom images instead of usingMarker
and noticedMarker
is consuming the map context instead of refs which feels like a nicer API for extending or building on top ofmapkit-react
.