w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Google maps - LatLng change my values in android

One option is to leverage the concept of Geohashing to evaluate equality based on proximity between two points. Geohashes sizes (distance) can be configured upon instantiation. So in your example you could construct to Geohashes like so:

GeoHash myLocHash =
GeoHash.withCharacterPrecision(store.getLatitude(), store.getLongitude(),
7);
GeoHash markerLocHash =
GeoHash.withCharacterPrecision(marker.getPosition().latitude,
marker.getPosition().longitude, 7);

if (myLocHash.equals(markerLocHash)) {
    // Same location +/- .61 km margin of error
}

This is probably overkill for what you need, but can be a really handy option for other applications. Here is a great Java library for Geohashes:

https://github.com/kungfoo/geohash-java

More reading on Geohashes:

http://en.wikipedia.org/wiki/Geohash





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.