我正在尝试使用嵌入式 GPS 定位设备(例如应用程序共享位置)。我读过它是可能的enableHighAccuracy: true
。
如何enableHighAccuracy: true
在此代码中设置?我尝试了不同的位置,但它不起作用。
<script type="text/javascript">
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var accuracy = position.coords.accuracy;
var coords = new google.maps.LatLng(latitude, longitude);
var mapOptions = {
zoom: 15,
center: coords,
mapTypeControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var capa = document.getElementById("capa");
capa.innerHTML = "latitude: " + latitude + ", longitude: " + ", accuracy: " + accuracy;
map = new google.maps.Map(document.getElementById("mapContainer"), mapOptions);
var marker = new google.maps.Marker({
position: coords,
map: map,
title: "ok"
});
});
} else {
alert("Geolocation API is not supported in your browser.");
}
</script>