Dear all,
I have an small problem that I don't know how to solve it. I have a
map where the user can add markers, here we have the function when the
user clic in the map.
function addMarker() {
var id = $('route_id').value;
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
//use the bounds data to find the mid point
var lngSpan = (northEast.lng() - southWest.lng())/2;
var latSpan = (northEast.lat() - southWest.lat())/2;
//make a new latitude and longitude point with the mid point data
var latlng = new GLatLng(southWest.lat() + latSpan, southWest.lng() +
lngSpan);
if (!latlng)
return;
queryURL = '/routes/'+ id +'/markers/new';
GDownloadUrl(queryURL, function(data, responseCode) {
map.openInfoWindow(latlng, data);
// my problem starts here
f = document.getElementByID("new_marker");
f.getElementByID("marker_lat").value = latSpan;
f.getElementByID("marker_lng").value = lngSpan;
});
};
In /route/x/markers/new I have the form:
<form action="/routes/2-madrid/markers" class="new_marker"
id="new_marker" method="post" onsubmit="new Ajax.Request('/routes/2-
madrid/markers', {asynchronous:true, evalScripts:true,
onComplete:function(request){javascript: addMarkerToMap();},
parameters:Form.serialize(this)}); return false;">
<input id="marker_lat" name="marker[lat]" type="hidden" />
<input id="marker_lng" name="marker[lng]" type="hidden" />
<p>
<label for="marker_description">Description</label>
<textarea cols="10" id="marker_description"
name="marker[description]" rows="5"></textarea>
</p>
<p>
<input id="marker_icon_mrkr_warning" name="marker[icon]" type="radio"
value="mrkr_warning" /> <img alt="Mrkr_warning" src="/images/pois/
mrkr_warning.png?1220011198" />
<input id="marker_icon_mrkr_water" name="marker[icon]" type="radio"
value="mrkr_water" /> <img alt="Mrkr_water" src="/images/pois/
mrkr_water.png?1220011138" />
</p>
<p>
<input name="commit" type="submit" value="Add marker" />
</p>
</form>
As you can view, in this form there are two hidden fields for latitude
and longitude. My problem is that I don't know how initialize they, in
this case, the marker_lat value will be latSpan and marker_lng will be
lngSpan. But it doesn't work becasue I don't know how to access the
form with ID new_marker.
Can anybody help me?
Thanks a lot
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---