How to obtain an address from latitude and longitude

ciginfo

Well-Known Member
Licensed User
Longtime User
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".
 

warwound

Expert
Licensed User
Longtime User
Can you post an example latitude and longitude that do not return an address?

Reverse geocoding is a bit hit and miss for many parts of the world.

Martin.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Hmmm....

Both of the coordinates you posted work for me, i just tested them in the Geocoder demo code.

Are you running the Geocoder on an emulator or a real device?
I'm not sure but seem to remember that the emulator does not support the Geocoder.

If you are running on a real device then can you post what device this is and which version of android it is running?

Finally can you simply reboot the device and try the Geocoder demo again?
(This post contains info about a reboot fixing the Geocoder: http://www.b4x.com/forum/additional...ates/17115-geocoder-library-3.html#post138643).

Martin.
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
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
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Look at the reference for the Address object: http://www.b4x.com/forum/additional...updates/17115-geocoder-library.html#post97857.

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.

Martin.
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
Other problem
How to extract data from Adress1, I have to display (Town, number street, street etc) on one line, no on listview.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
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.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
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?
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
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?
 
Last edited:
Upvote 0

warwound

Expert
Licensed User
Longtime User
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?

Martin.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
more accurate number..


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.
 

Attachments

  • LatLon.png
    LatLon.png
    216.6 KB · Views: 374
Upvote 0

warwound

Expert
Licensed User
Longtime User
Is (32.89464733333333, -96.9746748333333) the equivalent decimal degrees coordinate?
https://maps.google.co.uk/maps?q=32...647,96.974675&sspn=0.123671,0.264187&t=m&z=15

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);
   }
}

Martin.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
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
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Thanks friends, but sorry that's not even close.
kind of weird
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
@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.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
@Martin, Marcick,
You were both right and I think you worked on the first values I gave you, not the ones pictured on my
cell phone.

@klaus,
Thanks for the great tip.. I will act accordingly.
 
Upvote 0
Top