OSMDROID:错误:不兼容的类型:IGeoPoint无法转换为GeoPoint

时间:2016-04-20 11:18:04

标签: android osmdroid

我正在构建一个混合和匹配各种来源的示例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();

我开始收到以下错误(参考上面的最后一行):

  

错误:不兼容的类型:IGeoPoint不能   转换为GeoPoint

我使用的是Android Studio 2.0,osmdroid 4.3,slf4j 1.6.1

错误消息对我来说没什么意义,因为我没有声明或导入所说的IGeoPoint类。关于如何解决这个问题的任何建议将不胜感激。

3 个答案:

答案 0 :(得分:3)

OverlayItem.getPoint()返回一个IGeoPoint,而Projection.toPixels()需要一个IGeoPoint。所以:

IGeoPoint in = overlayItemArray.get(0).getPoint();

mapview.getProjection().toPixels(in, out);

(不要回到旧版本,但要升级到最新版本!)

答案 1 :(得分:1)

解决方法:将osmdroid版本从4.3更改为3.0.x. 3.0.x中不存在IGeoPoint类,但在4.3中它存在。

注意:版本4.2与IMapController

具有相同的问题

解决方案:将声明更改为private IGeoPoint startPoint;IMapController更改声明,我的代码与版本4.3+兼容。

答案 2 :(得分:-2)

public class ProjectEntryExt : PXGraphExtension<ProjectEntry>
{
    public class cancelled : Constant<string>
    {
        public cancelled() : base(ProjectStatus.Cancelled) {; }
    }

    [PXViewName(Messages.Project)]
    public PXSelect<PMProject, Where<PMProject.baseType, Equal<PMProject.ProjectBaseType>,
        And<PMProject.nonProject, Equal<False>, And<PMProject.isTemplate, Equal<False>,
        And<PMProject.status, NotEqual<cancelled>,
        And<Match<Current<AccessInfo.userName>>>>>>>> Project;

    [PXMergeAttributes(Method = MergeMethod.Append)]
    [PXRestrictor(typeof(Where<PMProject.status, NotEqual<cancelled>>),
        "Given Project/Contract '{0}' is cancelled", typeof(PMProject.contractCD))]
    public void PMProject_ContractCD_CacheAttached(PXCache sender) { }
}