Last active
August 29, 2015 14:19
-
-
Save hanislovingit/638fbe2cbef24372551a to your computer and use it in GitHub Desktop.
Mapbox-creation-api-polygon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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