Home » Android » Android GeoPoint with lat/long values

Android GeoPoint with lat/long values

Posted by: admin April 23, 2020 Leave a comment

Questions:

I am trying to get a GeoPoint for -23.4456 by 45.44334

What values do I pass into the constructor of the GeoPoint as it take Ints only.

How to&Answers:

GeoPoint coordinates are based in microdegrees (degrees * 1e6) — written here

float lat = -23.4456f;
float lng = 45.44334f;
GeoPoint gp = new GeoPoint((int)(lat * 1E6), (int)(lng * 1E6));

Answer:

rather than repeating the math throughout my app, i prefer to create a LatLonPoint:

private static final class LatLonPoint extends GeoPoint {
    public LatLonPoint(double latitude, double longitude) {
        super((int) (latitude * 1E6), (int) (longitude * 1E6));
    }
}

then wherever i need to create a GeoPoint and i have a lat/lon i just do

GeoPoint point = new LatLonPoint(37.234569, -122.123456);

there really should be a lat/long constructor on GeoPoint in the first place.

Answer:

I took the lat/long from this page and wrote it without a point…it worked very well, my home is there, where it should be 😉

so instead of (above) 34.234569 just write 34234569…remember: 1e6 is 1000000, nothing else 😉

Answer:

I am finding the solution may be it will help you.

1)First you have data(Location) in degree formate.
2)By the Equation you have to multiply it by 1000000
3)now ,you have particular GEO POINT Location .

Like here ;if I have location like : Latitude:23.0395677 and Longitude:72.5660045°
So, your GeoPoint(23039568,72566045);