【问题标题】:GeoPoint not working when passed a variable传递变量时 GeoPoint 不起作用
【发布时间】:2012-04-26 02:03:58
【问题描述】:

我是 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!");

【问题讨论】:

  • 你检查过 intLat 的值是什么,你得到的值是正确的

标签: android android-mapview


【解决方案1】:

地理点

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.

另请参阅link,了解如何将双精度浮点数转换为地理点。并确保你得到正确的 intLat 值

【讨论】:

  • 谢谢。我真正的问题是我没有得到正确的 intLat 值。我改变了:
  • 问题在于 intLat 的值错误。我没有正确读取资源文件。我认为它现在对我有用。
猜你喜欢
  • 1970-01-01
  • 2016-09-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-19
  • 2015-12-16
相关资源
最近更新 更多