API Google MAPS

Hello everybody,

I'm working with Version 3 of Google Maps JavaScript API, and I have the next code:

In a layout of my application:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/ libs/jquery/1.4.1/jquery.min.js"></script>

<script type="text/javascript" src="http://maps.google.com/maps/api/js? sensor=false"></script> <script type="text/javascript">   function initialize() {     var latlng = new google.maps.LatLng(28.142722, -15.448609);

  //Creatin a MapOptions object with tthe required properties     var myOptions = {       zoom: 3,       center: latlng,       mapTypeId: google.maps.MapTypeId.ROADMAP     };   //Creating the map     var map = new google.maps.Map(document.getElementById("mapilla"), myOptions);

  // add the marker itself       var marker = new google.maps.Marker({         position: latlng,         map: map,     draggable: true       });   }

  function add_marker(map, lat, lng) {   var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));   var myOptions = {     zoom: 10,     center: point,     //mapTypeControl: false,     mapTypeId: google.maps.MapTypeId.ROADMAP,

    navigationControlOptions: {       style: google.maps.NavigationControlStyle.ZOOM_PAN,       position: google.maps.ControlPosition.TOP_RIGHT     },

    mapTypeControlOptions: {       style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,       position: google.maps.ControlPosition.TOP_LEFT     },   };   var map = new google.maps.Map(document.getElementById("mapilla"), myOptions);

    // add the marker itself     var marker = new google.maps.Marker({       position: point,       map: mapilla,     draggable: true     });

  google.maps.event.addListener(marker, 'position_changed', function() {     var darwin = new google.maps.LatLng(marker.getPosition());

      $('input:text[name=event[lng]]').val(marker.getPosition().lng());       $('input:text[name=event[lat]]').val(marker.getPosition().lat());       //document.getElementById("Longitud").innerHTML = marker.getPosition().lng();       //document.getElementById("Latitud").innerHTML = marker.getPosition().lat();       //document.getElementById("lng").value = marker.getPosition().lng();       //document.getElementById("lat").value = marker.getPosition().lat();       //map.setZoom(1);       map.setCenter(marker.getPosition());   });   }

</script>

<body onload="initialize()"> . . . </body>

in the view for the form:

  <tr>       <th scope="row"><%= I18n.t("tog_conclave.fields.lat") %></th>       <td nowrap="nowrap"><%=f.text_field :lat, :class=>"fieldbox" %></

  </tr>   <tr>       <th scope="row"><%= I18n.t("tog_conclave.fields.lng") %></th>       <td nowrap="nowrap"><%=f.text_field :lng, :class=>"fieldbox" %></

  </tr>

and showing the map with this: <div id="mapilla"></div>

and the problem that i have is that i want to take the lng and lat from the marker but i can't.

How can I resolve it?

Thanks for your help.

> //document.getElementById("Longitud").innerHTML = marker.getPosition().lng();
> //document.getElementById("Latitud").innerHTML = marker.getPosition().lat();
I think you just have to uncomment these lines and add some html

like:

Longitude:

  Latitude: <span id="Latitud"></span>
Wherever you want to display it.

(or perhaps if you want to use disabled textfields with id="lng" |

“lat” uncomment:)

>	//document.getElementById("lng").value = marker.getPosition().lng();
> //document.getElementById("lat").value = marker.getPosition().lat();
Or if you want to display it in an InfoWindow of the marker, add and

open a infoWindow to the marker, which shows

        marker.getPosition().lat(); marker.getPosition().lng();

Hope I could imply something helpful. But I am not absolutly sure.

Perhaps someone with more google-maps expirience can tell you more than me. Or maybe you should try on the Google Maps API google-group ( )