Hi,
In my form-generator i want to use google maps so users can fill in
locations. I would like my generator to be able to support an
unlimited number of maps. The form-template generates an inputfield
(hidden) and a canvas-div for each map. My idea is to use javascript
to copy the latlang from a clickevent in the corresponding inputfield.
My html:
<label for='fieldname'>location</label>
<input class='hidden' id='fieldname' type='text' name='fieldname'
size='10' value='' readonly='readonly' />
<div id="fieldname_gmap" class="gmapform"></div>
My javascript:
var map = new Array();
var marker;
function init_gmap() {
//init maps
var mapzz = getElementsByClassName("gmapform", document, "DIV");
if ( mapzz ) {
for ( i=0; i<mapzz.length;i++ ) {
var loc =
document.getElementById(mapzz[i].id.replace("_gmap", "")).value;
if ( loc == "" ) { loc = "0,0"; }
loc = loc.split(",");
var latlng = new google.maps.LatLng(loc[0],loc[1]);
var myOptions = {
zoom: 7,
center: latlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
map[i] = new google.maps.Map(mapzz[i], myOptions);
google.maps.event.addListener(map[i], 'click',
function(event) { alert("here i would like to alert the mapid that
generated the event");});
}
}
}
I'm probable missing something very elementary here, but I cannot
figure out how to know the id of the canvas that triggered the
clickevent. Seems like event only has latlng, nothing else?
Any help on this is greatly appreciated!
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.