How to draw a polygon in google maps wrapping my points given a distance
I have a set of point开发者_高级运维s covering my city, lets call "gas stations" as example. I plotted all points om google maps. I need to draw a polygon, or several polygons, that represents the region covered by those gas stations within a 10km distance. My purpose is to find out regions that needs a gas station near by.
You want to use the harvesine-formula to measure the distance from your actual position to each other gas station and then search for the closest near by gas station.
You can do this easily by add a circle on top of the map at the same point as the gas stations
var circle_options = {
map: map,
center: location,
radius: 16093 // 10 miles converted ot meters
};
circle = new google.maps.Circle(circle_options);
http://code.google.com/apis/maps/documentation/javascript/overlays.html#Circles
Check this => http://gmaps-samples-v3.googlecode.com/svn/trunk/circle-overlay/circle-overlay.html
I'm using it in my app. It's easy to use and provided by google itself !
Check http://code.google.com/intl/fr-FR/apis/maps/documentation/javascript/demogallery.html to get more examples of cool stuff for GMaps V3
精彩评论