Skip to content
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

Geocoding/search plugin/widget/control #681

Open
prusswan opened this issue Oct 9, 2024 · 5 comments
Open

Geocoding/search plugin/widget/control #681

prusswan opened this issue Oct 9, 2024 · 5 comments

Comments

@prusswan
Copy link

prusswan commented Oct 9, 2024

Is your feature request related to a problem? Please describe.

Lonboard is great for visualizing large datasets, but sometimes I need to zero into a particular location so a search widget/control would be handy.

Describe the solution you'd like

Some means of building/integrating a search/geocoding control (that takes in textual input, turn it into location coordinates for the map to zoom/center to). User to provide JS event handling code for the respective search/geocoding service they prefer to use. But a sample can be provided for Nominatim/Mapbox etc

Describe alternatives you've considered

N/A. Might have to dig deeper into the widget internals if I had to do it myself

Additional context

I have some previous code done for folium (https://github.com/prusswan/folium/tree/multiple-and-generic-geocode-providers) - which is now able to support multiple geocoding services, although the custom geocode support (allowing users to define geocoding and event handling functions) was not incorporated due to maintenance reasons. (python-visualization/folium#1851)

@kylebarron
Copy link
Member

kylebarron commented Oct 10, 2024

Geocoding needs some sort of service running in the background, so it's unclear if we want that as part of the native Lonboard JS app. By having it separate, the user can decide which geocoder they want to use, and supply an API key if necessary.

You can have a separate widget and then set the view_state of the map whenever the geocoder widget resolves.

You could make your own anywidget-based widget with a little bit of JavaScript, and then wire up an event to set lonboard state.

If you wanted to have a pure-python widget, you could do something like this: https://stackoverflow.com/a/62015276

Because this is generic, it could be used with any widget-based map that lets you set the view state.

@prusswan
Copy link
Author

Geocoding needs some sort of service running in the background, so it's unclear if we want that as part of the native Lonboard JS app.

yeah for this to work as part of the exported html, there needs to be a way for the html to access an external service (could be anything from places autocomplete or some other search endpoint), I guess I am just looking for a least intrusive way to get this to work.

You could make your own anywidget-based widget with a little bit of JavaScript, and then wire up an event to set lonboard state.

A pure-Python widget should be sufficient for using within Jupyter. But if this can be part of the html, this will be more useful to the users who just want the visualization without having to deal with Python or JS. Actually, I just found #203 which is probably the other control I would need as well. Do you see any potential changes for lonboard to make it easier for users to add such controls (e.g. write less widget code)?

@kylebarron
Copy link
Member

kylebarron commented Oct 10, 2024

A pure-Python widget should be sufficient for using within Jupyter. But if this can be part of the html, this will be more useful to the users who just want the visualization without having to deal with Python or JS.

Well, the ideal solution would be to have some sort of lonboard-controls library, that has its own controls that integrate with Lonboard via Python widget properties. Though this means the controls will be rendered next to the map instead of on the same HTML object.

This means that users could use something off the shelf, but it wouldn't add to the complexity of the JS side of Lonboard.

@prusswan
Copy link
Author

ol_autocomplete_anywidget

I managed to get something working using anywidgets. However, it is only working for one provider, since I don't have a good solution yet for accepting provider options (minimally I think at least two JS functions will be needed for every provider - one for sending the request, and one for formatting the result). Ideally this could also be extended to support server-side queries against local data layers.

@kylebarron
Copy link
Member

Oh that looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants