src="http://www.google.com/jsapi?key=AIzaSyBkplC2WJePplXwHeSeiYCPh1QtHrLE_Oo"
if (navigator.geolocation) {enableHighAccuracy: true,
navigator.geolocation.watchPosition(function(position){
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var coords = new google.maps.LatLng(latitude, longitude);
var mapOptions = {
zoom: 13,
center: coords,
mapTypeControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("mapContainer"), mapOptions);
//mylocation as a marker on the map
var marker1 = new google.maps.Marker({
position: coords,
draggable: false,
map: map,
title: "Your current location!"
});
//the circle radius on the marker
var myCity = new google.maps.Circle({
center:coords,
radius:2000,
strokeColor:"#0000FF",
strokeOpacity:0.5,
strokeWeight:1,
fillColor:"#0000FF",
fillOpacity:0.1
});
myCity.setMap(map);
});
enableHighAccuracy: true;
}else {
alert("Geolocation API is not supported in your browser.");
}
问问题
231 次