Android GeoPoint with lat/long values

2019-01-11 09:57发布

问题:

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.

回答1:

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));


回答2:

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.



回答3:

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 ;)



回答4:

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);