I’m aiming to continually add new GPS coordinates to a satellite image, but it shows as
on the dashboard. Buried in comments you can see I’ve tried quite a few different things to sort this out to no avail. I think the latest one would be the best for updating data, if it looked like a map that is. I saw there was a similar one, but they just needed to remove figure=fig, and I already don’t have that. Thank you!
import dash
from dash.dependencies import Output, Input
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import random
import plotly.graph_objs as go
from collections import deque
#html layout
app = dash.Dash(__name__)
app.layout = html.Div(children=[
html.Div(
[
html.H1(children='Graphs'),
dcc.Graph(id = 'Map', animate = True),
dcc.Interval(
id = 'graph-update4',
interval = 1000,
n_intervals = 0
)
])
])
@app.callback(Output('Map', 'figure'),
Input('graph-update4', 'n_intervals'))
def update_graph4(n):
'''
Map = go.Figure(
data=go.Scattermapbox(
#random examples
lat=['38.91427','38.91538','38.91458',
'38.92239','38.93222','38.90842',
'38.91931','38.93260','38.91368',
'38.88516','38.921894','38.93206',
'38.91275'],
lon=['-77.02827','-77.02013','-77.03155',
'-77.04227','-77.02854','-77.02419',
'-77.02518','-77.03304','-77.04509',
'-76.99656','-77.042438','-77.02821',
'-77.01239'],
mode = 'markers'
#doesn't like layout?
#layout=go.Layout(title='Location', geo_scope='usa')
))
#second attempt
token = open("this is private I think").read()
Map = go.Figure(go.Scattermapbox(
mode = "markers",
lon = [-75, -80, -50], lat = [45, 20, -20],
marker = {'size': 20, 'symbol': ["bus", "harbor", "airport"]},
))
Map.update_layout(
mapbox = {
'accesstoken': token,
'style': "satellite", 'zoom': 0.7},
showlegend = False)
return Map
'''
#below here is my best attempt
data = []
data=go.Scattermapbox(
lat=37.709569,
lon=-77.02518,
mode='markers',
layout = go.Layout(title = 'GPS',
autosize=True,
hovermode='closest',
height=900,
width=1400,
mapbox=go.layout.Mapbox(
accesstoken='this is private I think',
bearing=0,
center=go.layout.mapbox.Center(
lat=38.91427,
lon=-89.220576,
pitch=60,
style='satellite',
zoom=15
))))
return {'data': [data],
'layout':[layout]
}
if __name__ == '__main__':
app.run_server()