2014-04-15 54 views

回答

0
<!DOCTYPE html> 
<html> 
<head> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 
<meta charset="utf-8"> 
<title>Circles</title> 
<style> 
    html, body, #map-canvas { 
    height: 100%; 
    margin: 0px; 
    padding: 0px 
    } 
</style> 
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> 
<script> 
// This example creates circles on the map with fixed radius of 5km 

var cityCircle; 

function initialize() { 
// Create the map. 
var mapOptions = { 
zoom: 14, 
center: new google.maps.LatLng(37.09024, -95.712891),//can use your center 
mapTypeId: google.maps.MapTypeId.TERRAIN 
}; 

var map = new google.maps.Map(document.getElementById('map-canvas'), 
    mapOptions); 

google.maps.event.addListener(map, "click", function (e) { 

//lat and lng is available in e object 
var latLng = e.latLng; 
// Construct the circleOptions 
var circleOptions = { 
    //optional to modify 
/* strokeColor: '#FF0000', 
    strokeOpacity: 0.8, 
    strokeWeight: 2, 
    fillColor: '#FF0000', 
    fillOpacity: 0.35,*/ 
    map: map, 
    center: latLng, 
    radius: 5000 //in meters apporx. 
}; 
// Add the circle for this city to the map. 
cityCircle = new google.maps.Circle(circleOptions); 
}); 

} 

google.maps.event.addDomListener(window, 'load', initialize); 

</script> 
</head> 
<body> 
<div id="map-canvas"></div> 
</body> 
</html> 
+0

感謝您的答覆,我們怎樣才能捕捉到緯度/經度和半徑。 – Madhu

相關問題