My main difficulty is too load properly the geojson data … I would like this behavior : as long as the visitor dont click on province layer we dont load the district data if he click we check if the data are already available or need to be loaded…
Here’s a very rough edit showing one possible approach. When the user clicks on the provinces, d3.json is called on the URL and the result is cached in a Map object:
I just wrote the caching logic into the ‘click’ callback function, but it probably makes sense to separate that out. Perhaps there are even better ways to do this.
Thank bgchen for this approch
The logic seems good but in your modification i get this error urlObj = TypeError: Object.fromEntries is not a function. (In 'Object.fromEntries(urls.map(url => [url.match(/\/([a-z]{2,3})\.json/)[1],url]))', 'Object.fromEntries' is undefined)
Many Thanks !
I implementing now … I can not merge directly because i am not familliar with this tool (and had make a lot of modification since the fork …).