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";
Titanium.Geolocation.forwardGeocoder(addr,function(evt)
{
forwardGeo.text = "lat:"+evt.latitude+", long:"+evt.longitude;
});
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); Ti.API.info(json); }; xhr.send();
-
It's not a KS key issue, forwardGeocoder is broken.