-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Implement Search and Geocoder #39
Comments
I prepared two samples for both search and autocomplete attached. Would be super cool to implement something like this in the library! Let me know if this would be something you would want to support! |
Thank you for the feature request! Since these APIs are not UI-related, how would you expect mapkit-react to help you to use them? I think that it should be possible to directly use the MapKit JS APIs without the need for a React-specific wrapper. But there is one rough edge: mapkit-react loads and initializes MapKit JS for you, but currently does not expose the Something that we could do would be to provide a function MyComponent() {
const mapkit = useMapkit(token);
return (
<input
type="text"
…
onChange={(e) => {
if (!mapkit) return;
const search = new mapkit.Search({});
search.autocomplete(e.target.value, (error, data) => {
if (error) return;
// …
});
}}
/>
);
} What do you think? Would an API like this one help for your use case? Footnotes
|
Hi @Nicolapps, thank you so much! I wasn't yet thinking too deep of an exact implementation on this though generally speaking I was thinking of using all the autoloading of the library and calling the MapKit JS APIs via individual hooks (e.g. We could even consider some implementation like this: function MyComponent() {
const search = useMapkitSearch(token, {});
return (
<input
type="text"
…
onChange={(e) => {
search.autocomplete(e.target.value, (error, data) => {
if (error) return;
// …
});
}}
/>
);
} What do you think? (I still think an additional Is this something easy or rather challenging to implement? |
Thank you for your reply! In my opinion, having a Also, it is not clear how the API you proposed handles the case when MapKit hasn’t finished loading yet. |
I would like to offer the user the possibility to Search for addresses or Points of Interests and would be cool to also do this with this library!
Might this be something we could add to the library? What would be the best way to do so? Maybe implement as a React hook? I would be willing to put some effort in this if you would give me some guidance on how the preferred implementation could look like.
I could also do a quick implementation in plain Javascript with the MapKit JS framework if this would help?
Thank you so much!
Edit: For the Geocoder there is a sample implementation in the Apple Developer portal at https://maps.developer.apple.com/sample-code/add-annotations/
For the search I could build something if this would help
The text was updated successfully, but these errors were encountered: