Hello,
Y try to obtain an address from longitude and latitude with Geocode. If I try the demo "Geocoder v2 00" I cannot obtain an address, it returns always "No Address matched the Latitude and Longitude".
Ah yes it works on a real device (Galaxy S2) and not on the emulator.
But it gives me only the number and name of the street but no the name of the town. Have I settings to do in geocoder?
Thank you
The Address object has many properties including 'AdminArea', 'SubAdminArea', 'SubLocality' etc.
The Geocoder will populate as many of these properties with values as it can, if the Geocoder does not have values for a property then the property will return a Null value.
So i'd suggest you perform a geocode and then when you get the results, log all Address object property values and see exactly what the geocoder is returning.
Unless you are reverse geocoding very obscure locations i'd expect the town name to be in one of the Address object properties.
If you have the lat-lon values, you can also use google service and parse the returned json. they give you the full address
and if the lat lon didn't hit a house then they give you the nearest adress.
Gosh!.. how come I didn't see this before.. Martin this is a great library that everyone needs and by far
is easier than using google apis directly.
Thank you so much indeed for this.
I have a question: how can I convert a value like: 32:53.67884, -96:58.48049 to something acceptable
by your library?
Thanks for this information..
After reading the wiki info, I couldn't find concrete answer, nor the form of the data I have.. I am using
the GPS example and a Huawei Y301A1.
When I put the lat lon values as I received them, in your lib, it gave me a place in Texas but way far from
where I am. 32:53.67884, -96:58.48049. how do you think I should convert these numbers to be used
with the geocoder demo?
What is the source of these coordinates - are they being obtained from the device?
Can you give me a rough idea of whereabouts 32:53.67884, -96:58.48049 is supposed to be?
The location is in Irving, Texas (near Dallas).
The source is my cell phone mentioned above using the GPS example of B4A
In my phone it is written like this: (see picture)
first number in black, then colon, then 2-digit number, then dot, then the rest.
I used the converter on this page: http://www.csgnetwork.com/gpscoordconv.html, scroll down to the last form where you can enter DDD and MM.MMMM values.
But the form refuses to accept -96 as DDD value, i entered 96 and after it converted the coordinate i added the minus sign.
(What a lot of work!).
This is the javascript function that the page used to convert the coordinates:
PHP:
function convertGps() {
var deg = 0;
var min = 0;
deg = document.inGPScoord.form3_gpsdeg.value;
min = document.inGPScoord.form3_gpsmin.value;
if (deg == "" || min == "") {
alert("Enter a value for GPS degrees and GPS min.");
} else if (deg > 180 || deg < 0) {
alert("Degrees should be between 0 and 180.");
} else if (min > 60 || min < 0) {
alert("Minutes should be between than 0 and 60.");
} else {
document.inGPScoord.form3_dec.value = (deg * 1.0) + min / 60.0;
document.inGPScoord.form3_ddd.value = deg;
document.inGPScoord.form3_mm.value = parseInt(min);
var remainder2 = min - (parseInt(min) * 1.0);
document.inGPScoord.form3_ss.value = parseInt(remainder2 * 60.0);
}
}
32:53.67884 means 32 degrees and 53.67884 minutes.
Take minutes/60 and add it to degrees value.
53.67884/60=0.8946 so your lat is 32.8946 in the most common format (degrees and decimal of degrees)
The same for lon -96:58.48049 that correspond to -96.97467
@Martin,
I went to that site and reproduced your calculation, and arrived at this result which is correct and showed
the exact location.
32.861314
-96.97417483333334
I used the lower calculator. I am now just hoping to find the calculation formula.
Instead of converting the values you get with the GPS example program you'd better to remove the conversion in the GPS program.
The GPS of the device returns decimal degrees and Erel converted them to DD:MM.MMMM in the program.