Can it be done in google maps v3?

0

I have this escript for google maps with which I can click and it shows me in a form its latitude and longitude, it works well and everything. my question is how can I migrate to version 3 of google maps? since the rest of my system is done in that version.

<script type="text/javascript">
function loadmap() {
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl()); 
      map.setCenter(new GLatLng(-36.5912852,-72.1210877), 15);    
      var point;
      point=map.getCenter();
      var marker = new GMarker(point);
      GEvent.addListener(map, "click", function (overlay,point){
         marker.setPoint(point);
         map.addOverlay(marker);
         marker.openInfoWindowHtml("<div style='font-size: 8pt; font-family: verdana'>Mi marca situada en<br>Latitud: " + point.lat() + "<br>Longitud: " + point.lng() + "</div>");
         GEvent.addListener(map, "click", function (overlay,point){
if (point){
      marker.setPoint(point);
      document.posicion.Latitud.value=point.lat()
      document.posicion.Longitud.value=point.lng()
   }
});
      });
   }



window.onload=loadmap
//]]>
</script>
    
asked by Juan Luis Guzman Sepulveda 25.05.2017 в 22:07
source

1 answer

0

How about,

Just listen to the event click on the map and then call event.latLng.lat (), event.latLng.lng ()

map.addListener('click', function(event) {
   var myLatLng = event.latLng;
   var lat = myLatLng.lat();
   var lng = myLatLng.lng();
});

here a sample fiddle link

    
answered by 25.05.2017 в 22:29