Created
October 22, 2011 04:15
-
-
Save hpneo/1305613 to your computer and use it in GitHub Desktop.
Generar un polígono con puntos, aleatoriamente.
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
map = new GMaps({ | |
div: '#map', | |
lat: -12.043333, | |
lng: -77.028333, | |
tilesloaded: function(){ | |
var path = []; | |
var bounds = map.map.getBounds(); | |
var ne = bounds.getNorthEast(); | |
var sw = bounds.getSouthWest(); | |
for(var i=1;i<=4;i++){ | |
lat = Math.random()*(ne.lat()-sw.lat())+sw.lat(); | |
lng = Math.random()*(sw.lng()-ne.lng())+ne.lng(); | |
map.addMarker({ | |
lat: lat, | |
lng: lng, | |
title: 'Marker #'+i | |
}); | |
path.push(new google.maps.LatLng(lat, lng)); | |
} | |
map.drawPolygon({ | |
paths: path, | |
strokeColor: '#333', | |
strokeOpacity: 0.6, | |
strokeWeight: 3, | |
fillColor: '#333', | |
fillOpacity: 0.3 | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment