This should work. Which version of Leaflet are you using?
Here, have a look at this jsFiddle.
It is important you get the arrays right.
First array is the polygon object [ in here the outer ring [ in here some [lat,lon],[,] close the outer ring], then the inner ring [ in here some [lat,lon],[,] close the inner ring ] close the polygon ].
scotland = L.polygon([[[60,-13],[60,0],[50,4],[50,-13]],
[[55.7,-4.5],[56,-4.5],[56,-4],[55.7,-4]]]);
scotland.addTo(map);
See example
var countyData = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": 0,
"properties": {
"ENTITYYR": 2010.0,
"NAME": "COUNTY1",
"FIPS": 25.0,
"FIPS_STR": "49025",
"COLOR4": 4
},
"geometry": {
"type": "Polygon",
"coordinates": [
[Long List Of Coordinates here]
]
}
}, etc
geojson = L.geoJson(countyData, {
style: function(feature) {
if (feature.properties.NAME === "COUNTY1") {
return {
color: "#ff3135",
weight: 1
};
}
if (feature.properties.NAME === "COUNTY2") {
return {
color: "#009b2e",
weight: 2
};
}
if (feature.properties.NAME === "COUNTY3") {
return {
color: "#ce06cb",
weight: 3
};
}
},
onEachFeature: onEachFeature
}).addTo(map);
Source https://github.com/bmcbride/bootleaf/blob/master/assets/js/app.js from BootLeaf template http://bmcbride.github.io/bootleaf/
Best Answer
Besides converting a feature to a Polygon with a dedicated function (see this answer), L.geoJson(geoJ) can be used to get a collection of objects. In case the input geoJ contains polygons, the objects themselves will be set to be L.Polygons, hence the conversion is done automatically. Summing up in both cases:
and
give access to the(each) polygon bounds.
Thanks to @nathansnider and @ghybs for the useful comments.