Add GeoJSON Outline
Try It Out
Zoom in to the marker and notice the polygon shape defined
Code
var geojsonFeature = { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ [ [ -6.337939202785492, 54.17750946223595 ], [ -6.337791681289673, 54.17731401762 ], [ -6.337337046861649, 54.17743489512197 ], [ -6.337392032146454, 54.177507107487024 ], [ -6.337371915578842, 54.17751652648189 ], [ -6.337402760982513, 54.17755734210142 ], [ -6.337433606386185, 54.177550277862466 ], [ -6.337492614984512, 54.1776334788225 ], [ -6.337939202785492, 54.17750946223595 ] ] ] } } ] } L.geoJSON(geojsonFeature).addTo(map);
View the source of this page to see fully how the map is created. In this example notice:
- We create a geojsonFeature variable
- We have coordinates for each of 9 points defined in geojsonFeature
- We use the geoJSON function with the geojsonFeature variable to add the shape to the map