Google Maps - Converting coordinates

We found that when converting the coordinates from Java double to Java int the notation makes all the difference:

When we used 1000000 instead of 1E6 the coordinates were rounded off and therefore up to one degree (110 km) off from the true location.


int lon = (int) item.getStatus().getGeo().mLongitude * 1000000
// rounded off coordinate lat :42000000 lon :-87000000

int lat = (int) (item.getStatus().getGeo().mLatitude * 1E6); 
// correct lat :42239902 lon :-87971504


Log.e("Map", "lat :" + lat + " lon :" + lon);
mPoints.put(item.getProfileImageUrl(), new GeoPoint(lat, lon));





As an Amazon Associate I earn from qualifying purchases.

No comments:

Post a Comment

Post Scriptum

The views in this article are mine and do not reflect those of my employer.
I am preparing to cancel the subscription to the e-mail newsletter that sends my articles.
Follow me on:
X.com (Twitter)
LinkedIn
Google Scholar

Popular Recent Posts

Most Popular Articles

apt quotation..