开发者

Google Maps API find My Location on Load Javascript

I have got a Google Maps and Places 开发者_运维百科API via javascript code. When the page loads it will automatically go to the Latitude defined in the code. Is there a way to have it AUTOMATICALLY go to where it thinks your location is, without having a button or search field?

Using this code currently:

google.maps.LatLng(37.783259, -122.402708);


Have you tried setting sensor=true when calling the API?

Source


 if(google.loader.ClientLocation)
    {
visitor_lat = google.loader.ClientLocation.latitude;
      visitor_lon = google.loader.ClientLocation.longitude;
};

new google.maps.LatLng(visitor_lat, visitor_lon);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜