Skip to content

Commit 2971db4

Browse files
committed
Serve local geojson files instead of doing it remotely
1 parent ed15227 commit 2971db4

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

  • apps/dash-opioid-epidemic

apps/dash-opioid-epidemic/app.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import pathlib
33
import re
4+
import json
45

56
import dash
67
import dash_core_components as dcc
@@ -289,19 +290,29 @@ def display_map(year, figure):
289290
dragmode="lasso",
290291
)
291292

292-
base_url = "https://raw.githubusercontent.com/jackparmer/mapbox-counties/master/"
293+
# base_url = "https://raw.githubusercontent.com/jackparmer/mapbox-counties/master/"
294+
base_url = APP_PATH
293295
for bin in BINS:
294296
geo_layer = dict(
295297
sourcetype="geojson",
296-
source=base_url + str(year) + "/" + bin + ".geojson",
298+
source=os.path.join(base_url, os.path.join("data", os.path.join(str(year) + "/" + bin + ".geojson"))),
297299
type="fill",
298300
color=cm[bin],
301+
# color="blue",
299302
opacity=DEFAULT_OPACITY,
300303
# CHANGE THIS
301304
fill=dict(outlinecolor="#afafaf"),
302305
)
303306
layout["mapbox"]["layers"].append(geo_layer)
304307

308+
link = os.path.join(base_url, os.path.join("data", os.path.join(str(year) + "/" + "10.1-12" + ".geojson")))
309+
310+
with open("/home/kids_on_drugs/Documents/Plotly/dash-sample-apps/apps/dash-opioid-epidemic/data/1999/0-2.geojson") as f:
311+
data = json.load(f)
312+
print("REACH")
313+
for feature in data["features"]:
314+
print(feature)
315+
305316
fig = dict(data=data, layout=layout)
306317
return fig
307318

0 commit comments

Comments
 (0)