I have an arraylist which consists of latLong object as shown below:
ArrayList < LatLng > latLngList = new ArrayList< LatLng >();
Note: LatLng is an object which has latitude and longitude values in double format i.e., Latitude is in double format and Longitude is in double format
The below are the values which 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 particular marker i get the latitude and longitude position and i try to compare it with the latLngList object to find whether the object is present in the latLngList.
I am doing it in the following way:
for(LatLng latLng : latLngList) {
marker.getPosition().equals(latLng); **Always returns false**
}
The marker position is returning me with the following latLng object:
lat/lng: (34.074226888265116,-118.39924816042185)
It is clear that the latitude and longitude object returned by marker is a bit lengthy and hence the comparison fails.
Is there a better way of comparing the latLng object?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…