Spaces:
Runtime error
Runtime error
alpergel
commited on
Commit
•
bb552aa
1
Parent(s):
323a18a
push fix
Browse files
app.py
CHANGED
@@ -18,24 +18,36 @@ def load_data():
|
|
18 |
)
|
19 |
return data
|
20 |
|
21 |
-
# Function to display the map
|
22 |
def map(data, lat, lon, zoom):
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
st.write(
|
25 |
pdk.Deck(
|
26 |
-
map_style="mapbox://styles/mapbox/
|
27 |
initial_view_state={"latitude": lat, "longitude": lon, "zoom": zoom, "pitch": 50},
|
28 |
layers=[
|
29 |
pdk.Layer(
|
30 |
"HexagonLayer",
|
31 |
-
data=
|
32 |
get_position=["Lon", "Lat"],
|
33 |
get_elevation="Number",
|
34 |
-
radius=100,
|
35 |
elevation_scale=4,
|
36 |
elevation_range=[0, 1000],
|
37 |
pickable=True,
|
38 |
extruded=True,
|
|
|
39 |
),
|
40 |
],
|
41 |
tooltip=tooltip
|
|
|
18 |
)
|
19 |
return data
|
20 |
|
21 |
+
# Function to display the map with corrected tooltip
|
22 |
def map(data, lat, lon, zoom):
|
23 |
+
# Since tooltips might not accept columns with spaces or special characters directly,
|
24 |
+
# we need to create a copy of the column with a name that's valid as a JavaScript identifier.
|
25 |
+
data_copy = data.copy()
|
26 |
+
data_copy['census_tract'] = data_copy['Census Tract #']
|
27 |
+
|
28 |
+
tooltip = {
|
29 |
+
"html": "<b>Census Tract #:</b> {census_tract}<br><b>Number:</b> {Number}",
|
30 |
+
"style": {
|
31 |
+
"backgroundColor": "steelblue",
|
32 |
+
"color": "white"
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
st.write(
|
37 |
pdk.Deck(
|
38 |
+
map_style="mapbox://styles/mapbox/light-v9",
|
39 |
initial_view_state={"latitude": lat, "longitude": lon, "zoom": zoom, "pitch": 50},
|
40 |
layers=[
|
41 |
pdk.Layer(
|
42 |
"HexagonLayer",
|
43 |
+
data=data_copy,
|
44 |
get_position=["Lon", "Lat"],
|
45 |
get_elevation="Number",
|
|
|
46 |
elevation_scale=4,
|
47 |
elevation_range=[0, 1000],
|
48 |
pickable=True,
|
49 |
extruded=True,
|
50 |
+
coverage=1,
|
51 |
),
|
52 |
],
|
53 |
tooltip=tooltip
|