Skip to content

Instantly share code, notes, and snippets.

@hanislovingit
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanislovingit/638fbe2cbef24372551a to your computer and use it in GitHub Desktop.
Save hanislovingit/638fbe2cbef24372551a to your computer and use it in GitHub Desktop.
Mapbox-creation-api-polygon
// Create the locations
var location1 = L.latLng(20,-20);
var location2 = L.latLng(20,20);
var location3 = L.latLng(-20,20);
var location4 = L.latLng(-20,-20);
// Create an array of locations. Notice the last one in the locations array is NOT the same as the first one, as this is not required in Mapbox API
var vertices = new Array(location1, location2, location3, location4);
// Create a PolylineOptions object that has some color value
var options = {
color: '#4fc',
fillColor: '#4fc'
};
// Create a polygon object
var polygon = L.polygon(vertices, options);
// Add the polygon object to the map
map.addLayer(polygon);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment