OSMDROID:错误:类型不兼容:IGeoPoint 无法转换为 GeoPoint [英] OSMDROID: error: incompatible types: IGeoPoint cannot be converted to GeoPoint
问题描述
我正在构建一个来自各种来源的混合和匹配示例 OSMdroid 应用.
I am building a sample OSMdroid app mixing and matching from various sources.
在使用这个示例代码,
import org.osmdroid.util.GeoPoint;
...
private void setOverlayLoc(Location overlayloc){
GeoPoint overlocGeoPoint = new GeoPoint(overlayloc);
//---
overlayItemArray.clear();
OverlayItem newMyLocationItem = new OverlayItem(
"My Location", "My Location", overlocGeoPoint);
overlayItemArray.add(newMyLocationItem);
}
...
@Override
public void draw(Canvas canvas, MapView mapview, boolean arg2) {
...
//overlayItemArray have only ONE element only, so I hard code to get(0)
GeoPoint in = overlayItemArray.get(0).getPoint();
我开始收到以下错误(参考上面最后一行):
I started receiving the following error (in reference to the last line above):
错误:类型不兼容:IGeoPoint 不能转换为 GeoPoint
error: incompatible types: IGeoPoint cannot be converted to GeoPoint
我使用的是 Android Studio 2.0、osmdroid 4.3、slf4j 1.6.1
I am using Android Studio 2.0, osmdroid 4.3, slf4j 1.6.1
错误消息对我来说意义不大,因为我没有声明或导入所说的 IGeoPoint
类.任何有关如何解决此问题的建议将不胜感激.
The error message makes very little sense to me, since i did not declare or import said IGeoPoint
class. Any suggestions as to how to go about this would be greatly appreciated.
推荐答案
OverlayItem.getPoint() 返回一个 IGeoPoint,而 Projection.toPixels() 需要一个 IGeoPoint.所以:
OverlayItem.getPoint() returns a IGeoPoint, and Projection.toPixels() needs a IGeoPoint. So :
IGeoPoint in = overlayItemArray.get(0).getPoint();
mapview.getProjection().toPixels(in, out);
(不要回到旧版本,而是升级到最新版本!)
(and don't go back to an older version, but upgrade to the latest one!)
这篇关于OSMDROID:错误:类型不兼容:IGeoPoint 无法转换为 GeoPoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!