-3
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.");
}
4

1 回答 1

0

这个工作示例HERE可能会回答您的问题。尝试单击给定地图上的任何标记,它将为您提供当前位置的方向。

于 2013-03-22T06:19:19.167 回答