Update app.py
Browse files
app.py
CHANGED
@@ -8,16 +8,41 @@ geojson_data = {
|
|
8 |
{
|
9 |
"type": "Feature",
|
10 |
"geometry": {
|
11 |
-
"type": "
|
12 |
-
"coordinates": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
},
|
14 |
"properties": {
|
15 |
-
"name": "
|
16 |
}
|
17 |
}
|
18 |
]
|
19 |
}
|
20 |
|
|
|
21 |
# Define the PyDeck layer
|
22 |
layer = pdk.Layer(
|
23 |
"GeoJsonLayer",
|
@@ -28,11 +53,37 @@ layer = pdk.Layer(
|
|
28 |
pickable=True
|
29 |
)
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
# Define the PyDeck view state
|
32 |
view_state = pdk.ViewState(
|
33 |
latitude=geojson_data['features'][0]['geometry']['coordinates'][1],
|
34 |
longitude=geojson_data['features'][0]['geometry']['coordinates'][0],
|
35 |
-
zoom=
|
36 |
)
|
37 |
|
38 |
# Set the Mapbox API key
|
|
|
8 |
{
|
9 |
"type": "Feature",
|
10 |
"geometry": {
|
11 |
+
"type": "LineString",
|
12 |
+
"coordinates": [
|
13 |
+
[8.7811, -0.7193], # Port-Gentil latitude and longitude
|
14 |
+
[15.8277, -0.2280] # Republic of Congo latitude and longitude
|
15 |
+
]
|
16 |
+
}
|
17 |
+
]
|
18 |
+
}
|
19 |
+
|
20 |
+
# Define the polygon geometry
|
21 |
+
polygon_geojson_data = {
|
22 |
+
"type": "FeatureCollection",
|
23 |
+
"features": [
|
24 |
+
{
|
25 |
+
"type": "Feature",
|
26 |
+
"geometry": {
|
27 |
+
"type": "Polygon",
|
28 |
+
"coordinates": [
|
29 |
+
[
|
30 |
+
[16.0315, -0.3797], # Polygon coordinates
|
31 |
+
[16.0315, -0.4515],
|
32 |
+
[15.9199, -0.4515],
|
33 |
+
[15.9199, -0.3797],
|
34 |
+
[16.0315, -0.3797]
|
35 |
+
]
|
36 |
+
]
|
37 |
},
|
38 |
"properties": {
|
39 |
+
"name": "Population: 200,000"
|
40 |
}
|
41 |
}
|
42 |
]
|
43 |
}
|
44 |
|
45 |
+
|
46 |
# Define the PyDeck layer
|
47 |
layer = pdk.Layer(
|
48 |
"GeoJsonLayer",
|
|
|
53 |
pickable=True
|
54 |
)
|
55 |
|
56 |
+
# Define the PyDeck layer for the line geometry
|
57 |
+
line_layer = pdk.Layer(
|
58 |
+
"GeoJsonLayer",
|
59 |
+
data=line_geojson_data,
|
60 |
+
get_source_position="geometry.coordinates",
|
61 |
+
get_target_position=lambda feature: feature["geometry"]["coordinates"][-1],
|
62 |
+
get_color=[255, 165, 0],
|
63 |
+
get_width=30000,
|
64 |
+
pickable=True
|
65 |
+
)
|
66 |
+
|
67 |
+
# Define the PyDeck layer for the polygon geometry
|
68 |
+
polygon_layer = pdk.Layer(
|
69 |
+
"GeoJsonLayer",
|
70 |
+
data=polygon_geojson_data,
|
71 |
+
get_fill_color=[0, 255, 255, 128],
|
72 |
+
get_line_color=[0, 0, 0],
|
73 |
+
get_line_width=3,
|
74 |
+
get_polygon="geometry.coordinates",
|
75 |
+
get_text="properties.name",
|
76 |
+
get_text_anchor="middle",
|
77 |
+
get_text_offset=[0, 20],
|
78 |
+
get_text_color=[255, 255, 255],
|
79 |
+
pickable=True
|
80 |
+
)
|
81 |
+
|
82 |
# Define the PyDeck view state
|
83 |
view_state = pdk.ViewState(
|
84 |
latitude=geojson_data['features'][0]['geometry']['coordinates'][1],
|
85 |
longitude=geojson_data['features'][0]['geometry']['coordinates'][0],
|
86 |
+
zoom=5
|
87 |
)
|
88 |
|
89 |
# Set the Mapbox API key
|