Plotly dash mapbox map won't zoom after reloadZoom to fit all markers in Mapbox or LeafletAuto-Pan/Center/Zoom Map within bounds of JSON markers loaded via .loadURLCannot move custom graphics along with map movements, using Mapbox Android SDKUsing python function output to update individual postgresql rowsMapbox Custom MarkerHow can I update the info inside a mapbox without reloading the figure in plotly dashControl MapBox Extent in Plotly Python APICannot zoom, when it updates (Plotly(dash) - Python)Uploading files with plotly-dash
Printing a list as "a, b, c." using Python
Group riding etiquette
Journal published a paper, ignoring my objections as a referee
Do universities maintain secret textbooks?
Lob Logical Read and lob read-ahead reads in NCCI
How to differentiate between two people with the same name in a story?
Ask one verbal question to figure out who is blind and who is mute among three persons
What am I looking at here at Google Sky?
What is the following VRP?
Am I required to correct my opponent's assumptions about my morph creatures?
Unexpected behavior after assignment of function object to function wrapper
What's the origin of the concept of alternate dimensions/realities?
I was given someone else's visa, stamped in my passport
How to animate a function plot
Properly unlinking hard links
Rapid change in character
Could a complex system of reaction wheels be used to propel a spacecraft?
Can UV radiation be safe for the skin?
Eliminate key lookup in execution plan
What is the motivation behind designing a control stick that does not move?
Which is the correct version of Mussorgsky's Pictures at an Exhibition?
Who declared the Last Alliance to be the "last" and why?
Can I lend a small amount of my own money to a bank at the federal funds rate?
What checks exist against overuse of presidential pardons in the USA?
Plotly dash mapbox map won't zoom after reload
Zoom to fit all markers in Mapbox or LeafletAuto-Pan/Center/Zoom Map within bounds of JSON markers loaded via .loadURLCannot move custom graphics along with map movements, using Mapbox Android SDKUsing python function output to update individual postgresql rowsMapbox Custom MarkerHow can I update the info inside a mapbox without reloading the figure in plotly dashControl MapBox Extent in Plotly Python APICannot zoom, when it updates (Plotly(dash) - Python)Uploading files with plotly-dash
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'd like to make a map with the ability to zoom (e.g. using the scroll-wheel). This works at first, but once the map is reloaded, zoom functionality stops working.
Another solution would be to have +/- zoom tools show up on the map.
Here's a minimal script that reproduces the issue.
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
app.layout = html.Div([
html.Button('Update Graph',id='get'),
html.P("On first load, zoom works fine. After reloading, zoom doesn't work anymore."),
dcc.Graph(id='map')
])
@app.callback(
Output('map', 'figure'),
[Input('get', 'n_clicks')])
def update_map_callback(n_clicks):
return
'data': [
go.Scattermapbox(
lat=df['lat'],
lon=df['long'],
mode='markers',
marker=dict(
size=4
)
)
],
'layout': go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='enter-your-mapbox-key-here',
center=dict(
lat=40,
lon=-100
),
zoom=2
)
)
if __name__ == '__main__':
app.run_server(debug=True)
When the page first pops up, one can zoom in and out on the map. I'd expect after pressing the 'update graph' button, the zooming should still work. However, when one presses the 'Update graph' button, the zoom level on the map becomes fixed.
python mapbox plotly-dash
add a comment |
I'd like to make a map with the ability to zoom (e.g. using the scroll-wheel). This works at first, but once the map is reloaded, zoom functionality stops working.
Another solution would be to have +/- zoom tools show up on the map.
Here's a minimal script that reproduces the issue.
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
app.layout = html.Div([
html.Button('Update Graph',id='get'),
html.P("On first load, zoom works fine. After reloading, zoom doesn't work anymore."),
dcc.Graph(id='map')
])
@app.callback(
Output('map', 'figure'),
[Input('get', 'n_clicks')])
def update_map_callback(n_clicks):
return
'data': [
go.Scattermapbox(
lat=df['lat'],
lon=df['long'],
mode='markers',
marker=dict(
size=4
)
)
],
'layout': go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='enter-your-mapbox-key-here',
center=dict(
lat=40,
lon=-100
),
zoom=2
)
)
if __name__ == '__main__':
app.run_server(debug=True)
When the page first pops up, one can zoom in and out on the map. I'd expect after pressing the 'update graph' button, the zooming should still work. However, when one presses the 'Update graph' button, the zoom level on the map becomes fixed.
python mapbox plotly-dash
add a comment |
I'd like to make a map with the ability to zoom (e.g. using the scroll-wheel). This works at first, but once the map is reloaded, zoom functionality stops working.
Another solution would be to have +/- zoom tools show up on the map.
Here's a minimal script that reproduces the issue.
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
app.layout = html.Div([
html.Button('Update Graph',id='get'),
html.P("On first load, zoom works fine. After reloading, zoom doesn't work anymore."),
dcc.Graph(id='map')
])
@app.callback(
Output('map', 'figure'),
[Input('get', 'n_clicks')])
def update_map_callback(n_clicks):
return
'data': [
go.Scattermapbox(
lat=df['lat'],
lon=df['long'],
mode='markers',
marker=dict(
size=4
)
)
],
'layout': go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='enter-your-mapbox-key-here',
center=dict(
lat=40,
lon=-100
),
zoom=2
)
)
if __name__ == '__main__':
app.run_server(debug=True)
When the page first pops up, one can zoom in and out on the map. I'd expect after pressing the 'update graph' button, the zooming should still work. However, when one presses the 'Update graph' button, the zoom level on the map becomes fixed.
python mapbox plotly-dash
I'd like to make a map with the ability to zoom (e.g. using the scroll-wheel). This works at first, but once the map is reloaded, zoom functionality stops working.
Another solution would be to have +/- zoom tools show up on the map.
Here's a minimal script that reproduces the issue.
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
app.layout = html.Div([
html.Button('Update Graph',id='get'),
html.P("On first load, zoom works fine. After reloading, zoom doesn't work anymore."),
dcc.Graph(id='map')
])
@app.callback(
Output('map', 'figure'),
[Input('get', 'n_clicks')])
def update_map_callback(n_clicks):
return
'data': [
go.Scattermapbox(
lat=df['lat'],
lon=df['long'],
mode='markers',
marker=dict(
size=4
)
)
],
'layout': go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='enter-your-mapbox-key-here',
center=dict(
lat=40,
lon=-100
),
zoom=2
)
)
if __name__ == '__main__':
app.run_server(debug=True)
When the page first pops up, one can zoom in and out on the map. I'd expect after pressing the 'update graph' button, the zooming should still work. However, when one presses the 'Update graph' button, the zoom level on the map becomes fixed.
python mapbox plotly-dash
python mapbox plotly-dash
asked Mar 27 at 23:11
user47389user47389
1
1
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
This issue has come up only recently - i have essentially the same problem that renders my app useless for the moment. See this entry in the community that provides a workaround - if you can live with a clunky replacement for your mouse wheel.
add a comment |
Thanks, had seen that, and while it's better than nothing, its is not really an acceptable workaround. Is there any way to alert mapbox to this issue? This is a major breakage.
add a comment |
I figured it out, thanks to the thread here. Trick is to modify the config. Here's a working example:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Button('Update Graph',id='get'),
html.P("On first load, zoom works fine. After reloading, zoom doesn't work anymore."),
dcc.Graph(id='map')
])
@app.callback(
[Output('map', 'figure'),
Output('map', 'config'),
],
[Input('get', 'n_clicks')])
def update_map_callback(n_clicks):
map_figure =
'data': [
go.Scattermapbox(
lat=[32],
lon=[-110],
mode='markers',
marker=dict(
size=4
)
)
],
'layout': go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='pk.eyJ1IjoidG9kZGthcmluIiwiYSI6Ik1aSndibmcifQ.hwkbjcZevafx2ApulodXaw',
center=dict(
lat=40,
lon=-100
),
zoom=2
)
)
map_config = dict(scrollZoom = True)
return map_figure, map_config
if __name__ == '__main__':
app.run_server(debug=True)
add a comment |
Similar to @user47389 answer the code modification that worked best for me was setting scrollZoom = True
explicitly when I defined the graph object in the first place
dcc.Graph(id='graph', config='scrollZoom': True)
Following the solution found here.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387872%2fplotly-dash-mapbox-map-wont-zoom-after-reload%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
This issue has come up only recently - i have essentially the same problem that renders my app useless for the moment. See this entry in the community that provides a workaround - if you can live with a clunky replacement for your mouse wheel.
add a comment |
This issue has come up only recently - i have essentially the same problem that renders my app useless for the moment. See this entry in the community that provides a workaround - if you can live with a clunky replacement for your mouse wheel.
add a comment |
This issue has come up only recently - i have essentially the same problem that renders my app useless for the moment. See this entry in the community that provides a workaround - if you can live with a clunky replacement for your mouse wheel.
This issue has come up only recently - i have essentially the same problem that renders my app useless for the moment. See this entry in the community that provides a workaround - if you can live with a clunky replacement for your mouse wheel.
answered Mar 28 at 3:19
The WecknessThe Weckness
1114 bronze badges
1114 bronze badges
add a comment |
add a comment |
Thanks, had seen that, and while it's better than nothing, its is not really an acceptable workaround. Is there any way to alert mapbox to this issue? This is a major breakage.
add a comment |
Thanks, had seen that, and while it's better than nothing, its is not really an acceptable workaround. Is there any way to alert mapbox to this issue? This is a major breakage.
add a comment |
Thanks, had seen that, and while it's better than nothing, its is not really an acceptable workaround. Is there any way to alert mapbox to this issue? This is a major breakage.
Thanks, had seen that, and while it's better than nothing, its is not really an acceptable workaround. Is there any way to alert mapbox to this issue? This is a major breakage.
answered Mar 28 at 13:23
dataNbeerdataNbeer
61 bronze badge
61 bronze badge
add a comment |
add a comment |
I figured it out, thanks to the thread here. Trick is to modify the config. Here's a working example:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Button('Update Graph',id='get'),
html.P("On first load, zoom works fine. After reloading, zoom doesn't work anymore."),
dcc.Graph(id='map')
])
@app.callback(
[Output('map', 'figure'),
Output('map', 'config'),
],
[Input('get', 'n_clicks')])
def update_map_callback(n_clicks):
map_figure =
'data': [
go.Scattermapbox(
lat=[32],
lon=[-110],
mode='markers',
marker=dict(
size=4
)
)
],
'layout': go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='pk.eyJ1IjoidG9kZGthcmluIiwiYSI6Ik1aSndibmcifQ.hwkbjcZevafx2ApulodXaw',
center=dict(
lat=40,
lon=-100
),
zoom=2
)
)
map_config = dict(scrollZoom = True)
return map_figure, map_config
if __name__ == '__main__':
app.run_server(debug=True)
add a comment |
I figured it out, thanks to the thread here. Trick is to modify the config. Here's a working example:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Button('Update Graph',id='get'),
html.P("On first load, zoom works fine. After reloading, zoom doesn't work anymore."),
dcc.Graph(id='map')
])
@app.callback(
[Output('map', 'figure'),
Output('map', 'config'),
],
[Input('get', 'n_clicks')])
def update_map_callback(n_clicks):
map_figure =
'data': [
go.Scattermapbox(
lat=[32],
lon=[-110],
mode='markers',
marker=dict(
size=4
)
)
],
'layout': go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='pk.eyJ1IjoidG9kZGthcmluIiwiYSI6Ik1aSndibmcifQ.hwkbjcZevafx2ApulodXaw',
center=dict(
lat=40,
lon=-100
),
zoom=2
)
)
map_config = dict(scrollZoom = True)
return map_figure, map_config
if __name__ == '__main__':
app.run_server(debug=True)
add a comment |
I figured it out, thanks to the thread here. Trick is to modify the config. Here's a working example:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Button('Update Graph',id='get'),
html.P("On first load, zoom works fine. After reloading, zoom doesn't work anymore."),
dcc.Graph(id='map')
])
@app.callback(
[Output('map', 'figure'),
Output('map', 'config'),
],
[Input('get', 'n_clicks')])
def update_map_callback(n_clicks):
map_figure =
'data': [
go.Scattermapbox(
lat=[32],
lon=[-110],
mode='markers',
marker=dict(
size=4
)
)
],
'layout': go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='pk.eyJ1IjoidG9kZGthcmluIiwiYSI6Ik1aSndibmcifQ.hwkbjcZevafx2ApulodXaw',
center=dict(
lat=40,
lon=-100
),
zoom=2
)
)
map_config = dict(scrollZoom = True)
return map_figure, map_config
if __name__ == '__main__':
app.run_server(debug=True)
I figured it out, thanks to the thread here. Trick is to modify the config. Here's a working example:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Button('Update Graph',id='get'),
html.P("On first load, zoom works fine. After reloading, zoom doesn't work anymore."),
dcc.Graph(id='map')
])
@app.callback(
[Output('map', 'figure'),
Output('map', 'config'),
],
[Input('get', 'n_clicks')])
def update_map_callback(n_clicks):
map_figure =
'data': [
go.Scattermapbox(
lat=[32],
lon=[-110],
mode='markers',
marker=dict(
size=4
)
)
],
'layout': go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='pk.eyJ1IjoidG9kZGthcmluIiwiYSI6Ik1aSndibmcifQ.hwkbjcZevafx2ApulodXaw',
center=dict(
lat=40,
lon=-100
),
zoom=2
)
)
map_config = dict(scrollZoom = True)
return map_figure, map_config
if __name__ == '__main__':
app.run_server(debug=True)
answered Apr 4 at 15:37
user47389user47389
1
1
add a comment |
add a comment |
Similar to @user47389 answer the code modification that worked best for me was setting scrollZoom = True
explicitly when I defined the graph object in the first place
dcc.Graph(id='graph', config='scrollZoom': True)
Following the solution found here.
add a comment |
Similar to @user47389 answer the code modification that worked best for me was setting scrollZoom = True
explicitly when I defined the graph object in the first place
dcc.Graph(id='graph', config='scrollZoom': True)
Following the solution found here.
add a comment |
Similar to @user47389 answer the code modification that worked best for me was setting scrollZoom = True
explicitly when I defined the graph object in the first place
dcc.Graph(id='graph', config='scrollZoom': True)
Following the solution found here.
Similar to @user47389 answer the code modification that worked best for me was setting scrollZoom = True
explicitly when I defined the graph object in the first place
dcc.Graph(id='graph', config='scrollZoom': True)
Following the solution found here.
answered Apr 9 at 8:10
FlowFlow
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387872%2fplotly-dash-mapbox-map-wont-zoom-after-reload%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown