Skip to first unread message

MSKH

unread,
Jan 30, 2019, 1:35:24 AM1/30/19
to MIT App Inventor Forum
Hi. How can I get the address from latitude and longitude?
Thanks in advance :) 

SteveJG

unread,
Jan 30, 2019, 8:28:42 AM1/30/19
to mitappinv...@googlegroups.com
You can obtain a street address directly from the LocationSensor (CurrentAddress) where this is based on  your device's present latitude and longitude.  You cannot obtain  address information from an arbitrary latitude / longitude pair with Blocks. The LocationSensor can provide a CurrentAddress from the user's actual location .

To reverse geocode (what you need to do)  to determine the address of an arbitrary latitude and longitude pair, you can do some advanced coding using javascript using Google's Maps Javascript API . Get an API Key from Google. This service is not free., https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse    The technique uses Google's database to provide the address.

Alternatively, there are web pages that can convert a latitude/longitude into an address.  You might be able to use the Web component to capture the information this way.  I don't know if it is possible (never tried).  Here are several:  ONLINECONVERTERS


What you do to get an address depends on the source of your latitude and longitude information.   It is very easy to get a latitude and longitude from an address (use the LatitudeFromAddress and LongitudeFromAddress blocks of the LocationSensor)  butthe reverse is only possible by using LocationSensor coordinates with the CurrentAddress block if you only use Blocks.



Regards,
Steve

MSKH

unread,
Feb 1, 2019, 12:42:06 AM2/1/19
to MIT App Inventor Forum
Thanks :)
Reply all
Reply to author
Forward
0 new messages