<!DOCTYPE html> <html> <head> <title>Accessing arguments in UI events</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <style> html, body, #map-canvas { height: 100%; margin: 0px; padding: 0px } </style> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <script> var index=0; function initialize() { var mapOptions = { zoom: 4, center: new google.maps.LatLng(65.0126304,25.4703071) }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); google.maps.event.addListener(map, 'click', function(e) { placeMarker(e.latLng, map); }); } function placeMarker(position, map) { var marker = new google.maps.Marker({ position: position, map: map }); var infowindow = new google.maps.InfoWindow({ content : "<input id='myText" + index + "' type='text'>", id : index }); map.panTo(position); google.maps.event.addListener( marker, "click", function() { infowindow.open( map, marker ); }); google.maps.event.addListener( infowindow, "closeclick", function(e) { infowindow.setContent("<input id='myText" + infowindow.id + "' type='text' value='" + document.getElementById("myText" + infowindow.id).value + "'>"); }); index++; } google.maps.event.addDomListener(window, 'load', initialize); index++; </script> </head> <body> <div id="map-canvas"></div> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)