Get Current Coordinates with Geolocation API

Hi Expert..i need a help

How to get current latitude and longitude using Geolocation API...
why geo API..because if i get the coordinates using SensorLocation .. its slow response when inside of building...but if i use geolocation API ... its more faster i guess.

any other idea?

Regard

The Geolocation API requires a Google API Key

It uses cell tower and WIFI nodes to produce location coordinates. As a result it is not as precise as using GPS.

App Inventor has no built-in control to access the API I imagine access would be using cURL which I do not know how it would be implemented in AI2.

I haven't tried using the Geolocation API but do not believe one can do it with App Inventor. Someone else might have a different opinion.

Inside of a building using the LocationSensor, you depend on WIFI or network because you probably will have no or a weak GPS radio signal. I think you could force the Provider to passive using the LocationSensor. If you use a cell phone, you should also have be able to set the Provider to network. Try that and you might get some kind of response indoors.

Wireless Networks use triangulation to determine the location of a device. The location information is obtained more rapidly than the data obtained from a GPS fix . A GPS fix can take from a few seconds under a clear sky to a30 or 40 seconds with a modern GPS reciever. A network fix is very fast. However the data provided by Wireless Networks is less reliable than most GPS fix's. Ordinarily network geo-location is not as precise as the information provided by a GPS. Mobile phones get the cell tower IDs from the nearest three or four cell towers in the vicinity. The technology uses the time difference of arrival to get your “exact” location within 10-50 meters of accuracy with 10-15 seconds. This method is called MS-Assist for GSM phones. A fall back method is called Cell ID. Cell ID is a passive guess of about 1.7 to 8 km (1-5 miles ) in accuracy and is possibly used if MS-Assist doesn't report sufficient certainty to get a position fix less than 100 meters (the minimum performance threshold for MS-Assist).

Faster :slight_smile: perhaps but less precise :frowning: Accuracy is imprecise compared to GPS.

Regards,
Steve

you can use the web component to send a Post request
for an example see here App Inventor Tutorials and Examples: Dropbox | Pura Vida Apps
How to work with the web component and an API by Stephen

Geolocation requests are sent using POST to the following URL:
https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

From the API documentation "You can then use cURL to make your request from the command line:

$ curl -d @your_filename.json -H "Content-Type: application/json" -i "https://www.googleapis.com/geolocation/ "

Is an explicit example showing how to do that with the Geolocation API forthcoming?

to use that API seems to be straight forward...
@yudha_anshori might want to try something, and if you get stuck, then post a screenshot of your relevant blocks...

Taifun

Thank You Steve for explaining

the codes above can get current location using geolocation...this html file stored in a server.
so...how to get these values and put them into appinventor as a input-values...and than we can map it in a maps

any idea ?

Regard

You could use the Map component or the ActivityStarter or a Google Static Map using a WebViewer to display a map. You also might be able to use html using the example here HTML Geolocation API

This example shows how to show a map using a LocationSensor How to put my location on a map and the Map component. Once you capture your geocoordinates using the html/server, you would do something similar to create your map with the coordinates your server provides rather than what the GPS provides.