I have a button to featch coordinates, but it stopped working, i have
no idea what to change, i am confused as to why its stopped working,
some talk about passing keys, updating api, can someone have a look at
my code it all stopped working yesterday for no reason



------------------------------

<script type="text/javascript" language="JavaScript">
/* adjust here the field names if they are not correct */
var apiKey = "{googleApiKey}";
var postalCodeField = 'field_postcode';
var cityField = 'field_city';
var countryField = 'field_country';
var latitudeField = 'field_latitude';
var longitudeField = 'field_longitude';

function fetchCoordinates() {
  /* here you should not change anything  */
  var gRequest = null;
  var postalcode = document.getElementById(postalCodeField).value;
  var city = document.getElementById(cityField).value;
  var country = document.getElementById(countryField).value;

  if(postalcode == '' || city == '' || country == '' ) {
    /* you can change the error message here */
    alert("Please fill in the address fields first");
  }
  else {
    var gRequest = "http://maps.google.com/maps/geo?q="+postalcode+
"+" +city+ "+" +country+
"&callback=getCoordinates&output=JSON&key="+apiKey;
    var scriptObj = document.createElement("script");
    scriptObj.setAttribute("type", "text/javascript");
    scriptObj.setAttribute("src", gRequest);
    document.getElementsByTagName("head").item(0).appendChild
(scriptObj);
  }
}
function getCoordinates(data) {
  switch(data.Status.code) {
    case 610:
      /* you can change the error message here */
      alert("Api key not valid: {googleApiKey}");
      break;
    case 603:
    case 602:
    case 601:
    case 500:
      /* you can change the error message here */
      alert("Cannot get coordinates for this address");
      break;
    case 200:
      document.getElementById(latitudeField).value = data.Placemark
[0].Point.coordinates[1];
      document.getElementById(longitudeField).value = data.Placemark
[0].Point.coordinates[0];
      break;
  }
}
</script>
<!-- You can change the "value" (The label on the button) here -->
<input type="button" class="button" onclick="fetchCoordinates();"
value="Fetch Map"/>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to