Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Map V2 Android and iOS place latlng decimal places

There is an Android as well as iOS application that I am working on. Both the applications use google's PlaceAutocomplete controller to get a location's lat-long. In iOS we get lat-long upto 6 decimal places sometimes 5 also. Where as in android we get more than 6 decimal places. The precision of the same location coordinate for Android and iOS differs.

For example consider location Pune
             Android Latlng: 18.520431,73.856744
                 iOS Latlng: 18.52043,73.856744

So as you can see there is difference between the precision of latitudes of the same location.

Is there a way to avoid this as my application needs comparison of these lat-longs?

like image 608
Pritam Kadam Avatar asked Jun 22 '16 10:06

Pritam Kadam


People also ask

What is LatLng in Google map?

A LatLng is a point in geographical coordinates: latitude and longitude. Latitude ranges between -90 and 90 degrees, inclusive.

Can I get the location with Lat Long?

To search for a place, enter the latitude and longitude GPS coordinates on Google Maps. You can also find the coordinates of the places you previously found. Besides longitude and latitude, you can use plus codes to share a place without an address.

How do I see Geocodes on Google Maps?

Go to the Google Cloud Console. Click the Select a project button, then select the same project you set up for the Maps JavaScript API and click Open. From the list of APIs on the Dashboard, look for Geocoding API. If you see the API in the list, you're all set.


2 Answers

You should not rely on the precision of the coordinates to compare them because they can change or, as you experiment, vary between platforms.

Instead, you can set a tolerance to determine if two locations are the same. For example:

float YOUR_TOLERANCE = 1; // 1 meter
if (location.distanceTo(otherLocation) < YOUR_TOLERANCE) {
    // Both locations are considered the same
}
like image 148
antonio Avatar answered Nov 15 '22 00:11

antonio


In android also there is three type of location :

  1. GPS_PROVIDER
  2. NETWORK_PROVIDER
  3. PASSIVE_PROVIDER

So, as per my coding experience i come to know that if you use :

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, new MyLocationListener());

you will get long precision of decimal like more then 14+ and if you will you use fusion of them with this :

LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, my_google_listener);

then you will get 6 to 7 digit of precision. try it !!!

like image 45
Dharvik shah Avatar answered Nov 15 '22 01:11

Dharvik shah