I have a dataset which already contains geojson. I can add it to my map with the following line of code.
And I get this
But I want to achieve this, where the surrounding area is covered up and my geojson shape is a hole in the middle of it.
According to the leaflet documentation
You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside.
So in theory something like:
var scotland = [[60,-13],[60,0],[50,4],[50,-13]]; L.Polygon([scotland,coordinatesOfShapeHole].addTo(map);
My problem is this function doesn't seem to like me passing in data.geojson or data.geojson.coordinates as the second parameter (coordinatesOfShapeHole);
Is there some way to convert data.geojson into a format the L.Polygon function is happy with?
Or alternatively do the same thing but with L.geoJson?