具有纬度/经度值的 Android GeoPoint

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3577866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:50:08  来源:igfitidea点击:

Android GeoPoint with lat/long values

androidandroid-mapview

提问by Ian Vink

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

我正在尝试通过 45.44334 获得 -23.4456 的 GeoPoint

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

我将哪些值传递给 GeoPoint 的构造函数,因为它只接受 Ints。

回答by Itsik

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

GeoPoint 坐标基于微度(度 * 1e6)——写在这里

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

回答by Ross M

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

与其在我的应用程序中重复数学运算,我更喜欢创建一个 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 并且我有一个纬度/经度我只是做

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

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

首先,GeoPoint 上确实应该有一个经纬度构造函数。

回答by ben0bi

I took the lat/long from this pageand 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 ;)

所以,而不是(上面) 34.234569 只写 34234569...记住:1e6 是 1000000,没有别的;)

回答by NovusMobile

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 .

1)首先你有学位格式的数据(位置)。2)根据公式,您必须将其乘以 1000000 3)现在,您有了特定的 GEO POINT 位置。

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

像这里;如果我有这样的位置:纬度:23.0395677 和经度:72.5660045° 所以,你的 GeoPoint(23039568,72566045);