我正在构建一个混合和匹配各种来源的示例 OSMdroid 应用程序。
在使用this sample code ,
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();
我开始收到以下错误(引用上面的最后一行):
error: incompatible types: IGeoPoint cannot be converted to GeoPoint
我正在使用 Android Studio 2.0、osmdroid 4.3、slf4j 1.6.1
错误消息对我来说意义不大,因为我没有声明或导入上述 IGeoPoint
类。将不胜感激任何关于如何解决这个问题的建议。
最佳答案
OverlayItem.getPoint() 返回一个 IGeoPoint,而 Projection.toPixels() 需要一个 IGeoPoint。所以:
IGeoPoint in = overlayItemArray.get(0).getPoint();
mapview.getProjection().toPixels(in, out);
(不要回到旧版本,而是升级到最新版本!)
关于android - OSMDROID:错误:类型不兼容:无法将 IGeoPoint 转换为 GeoPoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36742161/