构造函数的GeoPoint(双,双)是不确定的。这有什么错呢? [英] The constructor GeoPoint(double, double) is undefined. What's wrong with that?
本文介绍了构造函数的GeoPoint(双,双)是不确定的。这有什么错呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有错误:构造的GeoPoint(双,双)是不确定的。为什么会这样呢?怎样做是正确的?据我所知有链接的所有必要的库和语法似乎是正确的。
包com.fewpeople.geoplanner;进口android.app.Activity;
进口android.os.Bundle;进口com.google.android.maps.GeoPoint;
进口com.google.android.maps.MapActivity;
进口com.google.android.maps.MapController;
进口com.google.android.maps.MapView;公共类GeoplannerActivity延伸活动{
/ **当第一次创建活动调用。 * /
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main); 最终的MapView mMapView =(图形页面)findViewById(R.id.mapview); MapController mMapController = mMapView.getController(); 双X,Y;
X = 60.113337;
Y = 55.151317; mMapController.animateTo(新的GeoPoint(X,Y)); mMapController.setZoom(15); } 保护布尔isRouteDisplayed(){
返回false;
}
}
解决方案
GeoPoint对象有两个整型是在微度COORDS。我用这个方法为简单:
/ **
*一对坐标转换为GeoPoint对象
*
* @参数COORDS双重包含经度和纬度
* @返回GeoPoint对象为同一COORDS
* /
公共静态的GeoPoint coordinatesToGeoPoint(双[] coords)使用{
如果(coords.length→2){
返回null;
}
如果(COORDS [0] == Double.NaN || COORDS [1] == Double.NaN){
返回null;
}
最终诠释纬度=(int)的(COORDS [0] * 1E6);
最终诠释经度=(int)的(COORDS [1] * 1E6);
返回新的GeoPoint(经度,纬度);
}
另外,你的活动应该扩展MapActivity。
I am having error: "The constructor GeoPoint(double, double) is undefined". Why is it so? How to do it right? As I understand there are all necessary libraries linked and syntax seems to be right.
package com.fewpeople.geoplanner;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
public class GeoplannerActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final MapView mMapView = (MapView) findViewById(R.id.mapview);
MapController mMapController = mMapView.getController();
double x, y;
x= 60.113337;
y= 55.151317;
mMapController.animateTo(new GeoPoint(x, y));
mMapController.setZoom(15);
}
protected boolean isRouteDisplayed() {
return false;
}
}
解决方案
GeoPoint takes two integers that are coords in microdegrees. I use this method for simplicity:
/**
* Converts a pair of coordinates to a GeoPoint
*
* @param coords double containing latitude and longitude
* @return GeoPoint for the same coords
*/
public static GeoPoint coordinatesToGeoPoint(double[] coords) {
if (coords.length > 2) {
return null;
}
if (coords[0] == Double.NaN || coords[1] == Double.NaN) {
return null;
}
final int latitude = (int) (coords[0] * 1E6);
final int longitude = (int) (coords[1] * 1E6);
return new GeoPoint(latitude, longitude);
}
Also, your Activity should extend MapActivity.
这篇关于构造函数的GeoPoint(双,双)是不确定的。这有什么错呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文