Problem Description
When you pass a non us address to Ti.GeoLocation.forwardGeocoder(), it will fail returning null values.
Test Case
Same location queried through out Maps GoogleAPIs returns coords according the place.
var nonUS = "Hyderabad";
var Tokio = "Tokio";
var US = "Salt Lake city";
Titanium.Geolocation.forwardGeocoder( nonUS, function(evt)
{
Ti.API.info( "lat: "+evt.latitude+", long: "+ evt.longitude );
Ti.API.info( JSON.stringify(evt) );
});
xhr = Titanium.Network.createHTTPClient();
var query = nonUS;
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);
//17.385044,78.486671
};
xhr.send();
Extra info
The customer just want to show a proper annotation in the map to a particular location. i.e., need latitude and longitude values for "Ameerpet, Hyderabad"
var address = "Ameerpet,Hyderabad";
Titanium.Geolocation.forwardGeocoder( address, function(evt)
{
Ti.API.info( "lat: "+evt.latitude+", long: "+ evt.longitude );
Ti.API.info( JSON.stringify(evt) );
});
Right now a workaround will be changing from "Ameerpet, Hyderabad" to "Ameerpet-Hyderabad", that will return the right coordinates, except in cases where you send a full address, like: "Shantipath, Chanakyapuri New Delhi, India", which is a valid address and will return empty.
Docs are being updated with platform limitations here https://github.com/appcelerator/titanium_mobile/pull/3893 Marking this ticket as won't fix.
Doc Update The module provides two methods, [forwardGeocoder](Titanium.Geolocation.forwardGeocoder) and [reverseGeocoder](Titanium.Geolocation.reverseGeocoder) to convert between geographic coordinates and addresses. These methods map to MapQuest Open Nominatim Search Service. While this API has the advantage that it has no daily usage limits, please note that the data backing this API is crowd sourced and might not return proper values for valid addresses and geographic coordinates. If geocoding services are essential component of the application, developers are encouraged to use commercial geocoding providers.
Closing ticket as the issue will not fix.