How to get user position in Google Maps API?

I noticed that on the google api maps there is a "sensor" option.

+4
google-maps
source share
5 answers

The "sensor" in the GMaps API is not an option, it is an information parameter. Here is what the docs say:

Using the Google Maps API (s) requires what you specify, the application uses a sensor (such as a GPS locator) to determine the location of any Map API library or service request.

Google Maps does not know anything about your users, so it cannot provide its location. It's the other way around: you can determine the location of the user and provide them with Google Maps to place the location pointer, etc.

You have several options to get the user's location in JS:

If you are developing a device with touch-sensitive equipment (for example, a mobile phone with a GPS receiver), there must be certain ways to get the location directly from the device.

+14
source share

The approach to “getting a user’s position on Google maps” depends on which devices you are targeting.

HTML 5 is for Android, iPhone, and other mobile platforms that support HTML5. In this case, the browser can get the coordinates directly from GPS, without having to write code in their native language.

However, if you are developing QT in order to focus on Symbians and the like, you will need to write the code in your native language (C ++ in my case) to get the coordinates from your GPS and send it to the server to update the current location user. You will find detailed information about finding coordinates using the Qt Mobility API here .

+3
source share

Another way to get a user’s position is to enable:

<script type="text/javascript" src="https://www.google.com/jsapi"></script> 

On the page.

This creates a javascript object "google.loader.ClientLocation" that contains the latitude, longitude and address of the user.

Example:

 google.loader.ClientLocation = { "latitude": 51.817, "longitude": 19.3, "address": { "city": "Aleksandrow Lodzki", "region": "Lodz", "country": "Poland", "country_code": "PL" } }; 
+3
source share
0
source share

Sensor parameter is no longer required. from here :

The Google Maps API previously required you to enable a sensor parameter to indicate whether your application used a sensor to determine a user's location. This parameter is no longer required.

0
source share

All Articles