Computer >> Máy Tính >  >> Lập trình >> Javascript

Làm cách nào để hiển thị tốt nhất độ chính xác của vị trí địa lý HTML5 trên Bản đồ Google?


Để hiển thị độ chính xác của vị trí địa lý HTML5 trên Bản đồ Google, hãy sử dụng mã sau -

var lat = position.coords.latitude;
var longitude = position.coords.longitude;
var accuracy = position.coords.accuracy;
var center = new google.maps.LatLng(lat, longitude);

var a = new google.maps.Marker({
   position: center
   map:
   icon:
});

var mySphere = new google.maps.Circle({
   center: centerPosition,
   radius: accuracy,
   map:
   fillColor:
   fillOpacity:
   strokeColor:
   strokeOpacity:
});
map.fitBounds(mySphere.getBounds());