Click here to Skip to main content
15,886,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I am taking an input from user that is actually an info window in google maps which adds to teh description of the location marker. The problem is i am not able to save it i mean if i ahve inserted a marker/pin> and if i click an info window appears and takes an input i have amnaged so far but the problem is when you close that field and click again on the marker the text field does not have any thing.This is the line where i am taking an input from user
JavaScript
var infowindow = new google.maps.InfoWindow({
   content : "<input type='text'>"

This is my whole code.So in short i want when the user has closed the text field and clicks again on the marker he/she should see the description she entered.
Thanks anyways

JavaScript
<!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>
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 type='text'>"
});

  map.panTo(position);
google.maps.event.addListener( marker, "click", function() {
   infowindow.open( map, marker );
});
}

google.maps.event.addDomListener(window, 'load', initialize);

    </script>
  </head>
  <body>
    <div id="map-canvas"></div>
  </body>
</html>
Posted
Updated 2-Mar-14 21:44pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900