developmentseed / lonboard

A Python library for fast, interactive geospatial vector data visualization in Jupyter.
https://developmentseed.org/lonboard/latest/
MIT License
610 stars 30 forks source link

Geocoding/search plugin/widget/control #681

Open prusswan opened 2 days ago

prusswan commented 2 days ago

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 commented 1 day ago

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 commented 23 hours ago

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 commented 19 hours ago

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.