简体   繁体   中英

Storing double(latitudes) in arraylist changes the value

I have retrieved latitudes and longitudes from php and checked whether it has retrieved correctly or not. It has retrieved correctly, say latitudes: 102.11, 101.12, 100.01 and longitudes: 87.01, 101.01, 137.12. Now, I have store it in ArrayList which store LatLng types. When I read the values, longitudes are retrieved as it is, but all the latitudes are retrieved as 90.00. Why is it retrieving so?

Here is my code:

ArrayList<LatLng> locations = new ArrayList<LatLng>();
    LatLng loc;
    size=lats.size();//I have tried lngs.size() too, it didn't change the output
    for(int i=0;i<size;i++)
    {
        loc = new LatLng(lats.get(i), lngs.get(i));
        locations.add(loc);
    }

I have checked the data in lats arraylist and lngs arraylist, they have the data I have listed above.

Read the docs for LatLng . Latitude is restricted to the range [-90.0,90.0] . The constructor will clamp the value.

latitude The point's latitude. This will be clamped to between -90 degrees and +90 degrees inclusive.

longitude The point's longitude. This will be normalized to be within -180 degrees inclusive and +180 degrees exclusive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM