title: Coordinates Variables from Google Maps API to a php form
body: <p>so I'm looking for a way to pass the latitude and longitude from google maps api to a php textfield.
  So far I have the following code but I'm stuck, any help would be much appreciated.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script src="https://maps.googleapis.com/maps/api/js?sensor=false"&gt;
  &lt;/script&gt;
  
  &lt;script&gt;
  function initialize()
  {
  var mapProp = {
  center:new google.maps.LatLng(51.8978719,-8.471087399999988),  
  zoom:12,
  mapTypeId:google.maps.MapTypeId.ROADMAP
  };
  var map=new google.maps.Map(document.getElementById("googleMap")
  ,mapProp);
  
  citMarker=new google.maps.Marker({
  position:new google.maps.LatLng(51.885403000000000000,-8.534554100000037000),
  animation:google.maps.Animation.BOUNCE
  });
  
  var infowindow = new google.maps.InfoWindow({
  content:'&lt;b&gt;Cork IT&lt;/b&gt;'
  });
  
  infowindow.open(map,citMarker);
  citMarker.setMap(map);
  
  google.maps.event.addListener(citMarker, 'click', function() {
  map.setZoom(15);
  map.setCenter(citMarker.getPosition());
  infowindow.open(map,citMarker);
  });
  
  google.maps.event.addListener(map, 'rightclick', function(event) {
  placeMarker(event.latLng);
  });
  
  function placeMarker(location) {
  var marker = new google.maps.Marker({
  position: location,
  map: map,
  });
  
  var lat = location.lat();
  var long = location.lng();
  window.location.href = "testmap.php?dlat=" + lat + "&amp;dlong=" + long;
  
  var infowindow = new google.maps.InfoWindow({
  content: 'Latitude: ' + location.lat() +
  '&lt;br&gt;Longitude: ' + location.lng()
  });
  infowindow.open(map,marker);
  
  google.maps.event.addListener(marker, 'click', function() {
  infowindow.open(map,marker);
  });
  }
  }
  
  google.maps.event.addDomListener(window, 'load', initialize);
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div id="googleMap" style="width:500px;height:380px;"&gt;&lt;/div&gt;
  &lt;?php
  
  function getLatLong() {
  // Check if we have parameters dlat and dlong being passed to the script through the URL
  if (isset($_GET["dlat"]) &amp;&amp; isset($_GET["dlong"])) {
  
    // Put the two words together with a space in the middle to form "hello world"
      $lat = $_GET["dlat"];
      $long = $_GET["dlong"];
    // Print out some JavaScript with $hello stuck in there which will put "hello world"    into the javascript.
    echo $hello;
    echo $lat;
    echo $long;
  }
  }
  ?&gt;
  getLatLong();
  Lat 1:&lt;input type="text" size="20" maxlength="50" name="displayLat" value="&lt;?php echo $lat; ?&gt;"&gt;&lt;br /&gt;
  Long 1:&lt;input type="text" size="20" maxlength="50" name="displayLong"&gt;&lt;br /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So far it is displaying a google map, when you right click on the map an infowindow pops up giving the coordinates for the space, and 2 textfields are displayed below the map, what I am looking to do is to display the latitude and longitude in the form when you right click the map.</p>