Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

forwardGeocoder only works for one address

I'm attempting to use Titanium.Geolocation.forwardGeocoder that is in geolocation.js in the KitchenSink but it only seems to work with the one sample address used in the KS app. If I try any other address (and I've tried quite a few) it does not return a lat and long. On the Android it returns nothing and on the iPhone it returns 0. I haven't modified the code in any way, the only thing I'm doing is changing line 366 in KitchenSink 1.3 to have any other address. I thought that it could be an issue with the Google Map API key may have hit its limit or something since all KS apps are using the same API key, but I think only Android requires the key in the tiapp.xml, and I did try using my own key there as well. Does anyone have any idea? Here is the relavant code from KitchenSink:

var addr = "444 Castro Street, Mountain View, CA 94041";

    forwardGeo.text = "lat:"+evt.latitude+", long:"+evt.longitude;
— asked May 16th 2010 by Eric Wikman

2 Answers

  • Please see this ticket for details on how we are handling this: TIMOB-4880

    In the meantime, you can do the forward geocoding yourself very easily, something like this:

    xhr = Titanium.Network.createHTTPClient();
    var query = 'Pittsburgh PA 15202'; // or whatever you want to forward geocode
    xhr.open('GET', 'http://maps.googleapis.com/maps/geo?output=json&q=' + query);
    xhr.onload = function() {
        var json = JSON.parse(this.responseText);
    — answered November 30th 2011 by Tony Lukasavage
    • Tony,
      in tis case, what is the 24-hour limit ?

      — commented December 6th 2011 by Armindo Da Silva
    • To avoid, reinventing the wheel, how to you get the coordinates from the json object ?

      — commented December 6th 2011 by Armindo Da Silva
    • This is how I pull the latitude and longitude:

      var json = JSON.parse(this.responseText);
      if (!json.Placemark || !json.Placemark[0].Point || !json.Placemark[0].Point.coordinates) {
          alert('Unable to geocode the address');
      var point = {
          latitude: json.Placemark[0].Point.coordinates[1],
          longitude: json.Placemark[0].Point.coordinates[0]

      — commented December 12th 2011 by Tony Lukasavage
  • It's not a KS key issue, forwardGeocoder is broken.

    — answered May 22nd 2010 by Chris Reed
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.