В настоящее время мой код выглядит так: < /p>
import dash
from dash import Output, Input, State, html, no_update
import dash_leaflet as dl
import osmnx as ox
import json
from numpy import dtype
# Style-Funktion für GeoJSON-Features
def get_style(feature):
return {
"color": "rgba(0,0,0,0)", # Transparent
"weight": 5,
"opacity": 1,
"fillOpacity": 0
}
# create a style for the GeoJSON features where the color is dependent on the "use" attribute
def get_style_with_use(feature):
if feature['properties']['use'] == True:
return {
"color": "rgba(0,0,0,0)",
"weight": 2,
"opacity": 0.7,
"fillOpacity": 0
}
else:
return {
"color": "green",
"weight": 5,
"opacity": 0.9,
"fillOpacity": 0
}
# Hover-Style (blau)
hover_style = {
"color": "blue",
"weight": 7,
"opacity": 1,
"fillOpacity": 0.5
}
# GeoJSON with Dresdner streets
G = ox.load_graphml("dresden_saxony_germanyroad_network.graphml")
# add a attribute to the edges called "use" and set it to "TRUE"
for u, v, key, data in G.edges(keys=True, data=True):
data['use'] = True
geojson_data = ox.graph_to_gdfs(G, nodes=False, edges=True, fill_edge_geometry=True).to_json()
data = json.loads(geojson_data)
meta = data['features']
mapping = {}
for i in range(len(meta)):
mapping[meta['id']] = i
# print the Name of the Street on the Dash App as text below the map
# Dash-App mit Leaflet-Karte
app = dash.Dash(__name__)
app.layout = html.Div([
html.H1("Dresden Streets Map"),
dl.Map([
dl.TileLayer(),
dl.GeoJSON(
data=data,
id="geojson-dresden-streets",
style={
"color": "rgba(0,0,0,0)",
"weight": 5,
"opacity": 1,
"fillOpacity": 0
},
hoverStyle=hover_style
)
], style={'width': '1000px', 'height': '500px'}, center=[51.0504, 13.7373], zoom=12),
html.Div(id='container-output-text',
children='Enter a value and press submit')
])
@app.callback(
Output('container-output-text', 'children'),
Input('geojson-dresden-streets', 'n_clicks'),
State('geojson-dresden-streets', 'clickData'),
prevent_initial_call=True
)
def f1(input_, state_):
print(json.dumps(input_))
print(json.dumps(state_))
# id = mapping.get(str(state_['id']))
# print(state_['id'])
# print(id)
# # print datatype of data['features']
# print(type(data['features']))
# print(data['features'][id])
# data['features'][id]['properties']['use'] = False
print()
if __name__ == "__main__":
app.run(debug=True)
< /code>
Что я хочу сделать: < /p>
Создание карты - здесь как образец для Дрездена, Германия. #Done < /li>
Уливающие улицы должны быть синими #done < /li>
Нажимать на уличную изменение, добавленную функцию «Использование» из верного в False или VISE. Кроме того, улица должна изменить цвет с прозрачного на красный.>
Подробнее здесь: https://stackoverflow.com/questions/796 ... nd-leaflet
Измените свойство Geojson, нажав на карту, используя Dash и Listlet ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Добавить новый маркер, когда я нажимаю на карту (OpenStreetMap, Listlet JS)
Anonymous » » в форуме Jquery - 0 Ответы
- 8 Просмотры
-
Последнее сообщение Anonymous
-