0

我是 Android/Java 新手,当我尝试向它发送变量时创建 GeoPoint 时遇到问题,但是当我向它发送文字值时它可以正常工作。

在下面的代码块中,toast 消息显示正确的纬度(从 strings.xml 检索

如何使用变量设置纬度?

Integer intLat = Integer.valueOf(R.string.MexCityLat);
Toast.makeText(HelloGoogleMapsActivity.this, intLat, Toast.LENGTH_SHORT).show();

GeoPoint point = new GeoPoint(intLat , -99120000);  //this puts my point near North Pole
//GeoPoint point = new GeoPoint(19240000, -99120000);  //this puts my point in Mexico City

OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
4

1 回答 1

0

地理点

public GeoPoint(int latitudeE6,int longitudeE6)

构造具有给定纬度和经度的 GeoPoint,以微度 (度 * 1E6) 为单位。

参数:

 latitudeE6 - The point's latitude. This will be clamped to between -80 degrees and +80 degrees inclusive, in order to maintain accuracy in the Mercator projection.
 longitudeE6 - The point's longitude. This will be normalized to be greater than -180 degrees and less than or equal to +180 degrees.

另请参阅此链接以了解如何将双精度浮点数转换为地理点。并确保您获得正确的 intLat 值

于 2012-04-26T02:19:30.543 回答