I would like to simply get map coordinates from a click event but can’t figure it out. I can access the scatter data that’s overlayed but I want to get to the map itself.
Is it even possible to access Mapbox events in Dash?
Emil
February 13, 2020, 5:49pm
2
I an not sure about the Plotly maps, but in Dash Leaflet, you can get the click events. See e.g. example 1 here,
mapbox_ids = ["light-v9", "dark-v9", "streets-v9", "outdoors-v9", "satellite-streets-v9"]
# region Example 1
MAP_ID = "map-id"
BASE_LAYER_ID = "base-layer-id"
BASE_LAYER_DROPDOWN_ID = "base-layer-drop-down-id"
COORDINATE_CLICK_ID = "coordinate-click-id"
def render_example1():
comment = """ Marker with default icon, marker with custom icon, circle marker (fixed pixel radius),
circle (fixed physical radius), polyline, polygon and rectangle, all supporting tooltips and popups. """
return [
html.H1("Example 1: Basic components"),
html.P(comment),
dl.Map(id=MAP_ID, style={'width': '1000px', 'height': '500px'}, center=[56.05, 10.25], zoom=10, children=[
dl.TileLayer(id=BASE_LAYER_ID),
# Marker with tool tip and popup.
dl.Marker(position=[56, 9.8], children=[
dl.Tooltip("Marker tooltip"),
where the clicked lat lon is captured.