Google Maps HTML5 click to get lat, long

后端 未结 3 983
一生所求
一生所求 2020-12-25 11:23

I\'m trying to build a mobile HTML5 webapp in which user can click on the map to get lat/long from Google Maps. Is there a code example? I tried googling but only found some

3条回答
  •  余生分开走
    2020-12-25 11:50

    The code below will show you how to get the Long and Lat when the user clicks the map - Allow user to place marker on a google map

    google.maps.event.addListener(map, 'click', function( event ){
      alert( "Latitude: "+event.latLng.lat()+" "+", longitude: "+event.latLng.lng() ); 
    });
    

提交回复
热议问题