API Google MAPS

h0bit
Mon, 08 Nov 2010 13:44:00 -0000

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 type="text/javascript"
src="http://maps.google.com/maps/api/js?
sensor=false">

  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());
  });
  }




.
.
.


in the view for the form:


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


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


and showing the map with this:



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.

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at