Skip to content

Instantly share code, notes, and snippets.

@hanislovingit
Created April 22, 2015 02:10
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/3bc4d530de2cd91e2959 to your computer and use it in GitHub Desktop.
Save hanislovingit/3bc4d530de2cd91e2959 to your computer and use it in GitHub Desktop.
Bing-map-creation-api-polygon
// Create the locations
var location1 = new Microsoft.Maps.Location(20,-20);
var location2 = new Microsoft.Maps.Location(20,20);
var location3 = new Microsoft.Maps.Location(-20,20);
var location4 = new Microsoft.Maps.Location(-20,-20);
// Create an array of locations. Notice the last one in the locations array is the same as the first one
var vertices = new Array(location1, location2, location3, location4, location1);
// Create a Color object for use in PolygonOptions
var polygoncolor = new Microsoft.Maps.Color(100,100,0,100);
// Create a polygon object
var polygon = new Microsoft.Maps.Polygon(vertices,{
fillColor: polygoncolor,
strokeColor: polygoncolor
});
// Add the polygon object to the map
map.entities.push(polygon);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment