我和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!");
答案 0 :(得分:0)
<强>的GeoPoint 强>
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了解如何将double,float转换为geopoint。并确保你获得了正确的intLat值