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.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles