Comparing two LatLng objects in google map v2 android

I have an arraylist that consists of a latLong object, as shown below:

ArrayList < LatLng > latLngList = new ArrayList< LatLng >();

Note. LatLng is an object that has latitude and longitude values ​​in dual format, i.e. Latitude in dual format, and Longitude in dual format

The following are the values ​​that are stored in the above latLngList object :

Lat Long List:[lat/lng: (34.072516,-118.403609), lat/lng: (34.074227,-118.399248), lat/lng: (34.07304,-118.3995), lat/lng: (34.07304,-118.3995), lat/lng: (34.07304,-118.3995), lat/lng: (34.067856,-118.401485)]

Now, since I am dealing with google map v2 in android, whenever I click on a specific marker, I get the position of latitude and longitude, and I try to compare it with the latLngList object to find out if the object is present in latLngList .

I do it as follows:

 for(LatLng latLng : latLngList) {
       marker.getPosition().equals(latLng); **Always returns false**
 }

The marker position returns me with the following latLng object:

lat/lng: (34.074226888265116,-118.39924816042185)

, , , , , , .

latLng?

+5
5

LatLng, Marker. - Marker.getPosition() .

List Map, Marker.

Marker.getId() Marker, , onMarkerClick.

Edit:

gmaps-api-issues.

+5

latlngs . .

final LatLng[] latLngs = new LatLng[2];
latLngs[0] = new LatLng(lat, lng);
latLngs[1] = new LatLng(lat, lng);

if(latLngs1[0].equals(latLngs1[1])) {
//to do 
}                                                    
+2

, - latlng point markers, Location. , .

+1
0

You have 2 options that I can think of, one uses the quadtree library: http://koti.mbnet.fi/ojalesa/quadtree/quadtree_intro.htm which is easy to use and useful, the other is a very good answer from @geocodezip (in javascript)

var SameThreshold = 0.1;
if (google.maps.geometry.spherical.computeDistanceBetween(latlng1,latlng2) < SameThreshold)
marker1.setAnimation(google.maps.Animation.BOUNCE); 
0
source

All Articles