Closed JackDougherty closed 4 years ago
By crashing, do you mean the Point legend control is missing from the map? If that, I believe it is designed to behave this way. Let me know if you think it should be changed (so we have a single checkbox in the legend instead of no legend at all).
I looked further into this and there are two different issues here:
1) I was wrong that lack of variation in Group names crashes the map. Not sure why I thought this, because I cannot replicate it. In any case, I like your idea to allow the user to display the point legend, even if there is only a single checkbox.
2) Here's what definitely crashes the map (meaning it will not load anything): Currently, our book has bad instructions about how to remove polygons. We say this here in step F:
...
To remove polygons:
In the Polygons tab, set Polygon Legend Position (cell B4) to Off to hide it.
Also in the Polygons tab, set Polygon GeoJSON URL (cell B6) to remove that data from your map.
That last instruction is poorly written, probably by me!
If we hide the polygon legend in cell B4, it works fine. If we change polygon data to not display on start in B10, it works fine. But if we "clear" polygon cell B6, it crashes. Is it feasible to code the map so that it still loads if polygon B6 is empty?
Jack–
I couldn't really reproduce it. When I remove URL from the cell (so the cell is blank), the map loads all components apart from the polygons (see screenshots).
I think you might have left a space there or some other invisible character, in which case the map loaded indefinitely. I will add a trim()
function to make sure all leading and trailing space characters from the cell are removed before deciding whether to load or skip the GeoJSON.
Thanks for looking into this. In case it helps you to diagnose the underlying issue, here's my broken map https://jackdougherty.github.io/leaflet-maps-gs-v4-testing/index.html
and the linked Sheet (which you can edit) with polygon cell B6 blank, and no white spaces https://docs.google.com/spreadsheets/d/17-L_Vx-1YNCx0-fiLfJF4gxtsl0J5z1-bmGSzBrcV8s/edit#gid=745832354
Whatever solution you recommend sounds good to me
Please replace $('.ladder h6').get(0).click();
with this $('.ladder h6').first().click();
in map.js
, line 736. I will make sure to update it in the main repository.
Noticed this while testing. If by design, I can warn about it in the tutorial, but figured it's worth checking.
In Group column in the Google Sheet, if all entries are the same and therefore only "one" group, it crashes the map.