【问题标题】:Android ESRI map getting Failed to generate sequences for graphic errorAndroid ESRI 地图无法生成图形错误序列
【发布时间】:2013-12-14 13:38:46
【问题描述】:

我正在使用以下代码在我的 ESRI 地图中添加图形层。

public void footprintdata(String option)
 {  
  graphicsLayer.removeAll();

  if(option.equalsIgnoreCase("ALL"))
  {
   try 
   {    
    Graphic[] resultGraphics = new Graphic[footprintdata.size()];
    // Envelope to focus on the map extent on the results
    Envelope extent = new Envelope();

    for (i = 0; i < footprintdata.size(); i++) 
    {
     double lattitude = 0.0;
     double longitude = 0.0;  

     if(!footprintdata.get(i).getLatitude().equalsIgnoreCase(""))
     {
      lattitude = Double.parseDouble(footprintdata.get(i).getLatitude());
     }
     if(!footprintdata.get(i).getLongitude().equalsIgnoreCase(""))
     {
      longitude = Double.parseDouble(footprintdata.get(i).getLongitude());
     }     

     mLocation = new Point(XCoordinateFromLongitude(longitude), YCoordinateFromLatitude(lattitude));

     mapPoint = (Point) GeometryEngine.project(mLocation,
       SpatialReference.create(4326),mapView.getSpatialReference());  

     SimpleMarkerSymbol resultSymbol = new SimpleMarkerSymbol(Color.GREEN, 20, SimpleMarkerSymbol.STYLE.DIAMOND);
     // create graphic object for resulting location
     //PictureMarkerSymbol imagesymbolicon = new PictureMarkerSymbol(imagemarker(i));

     Graphic resultgraphics = new Graphic(mapPoint,resultSymbol);    
     resultGraphics[i] = resultgraphics;
     extent.merge(mapPoint);
    }

    graphicsLayer.addGraphics(resultGraphics);
    mapView.setExtent(extent, 100);
    mapView.zoomToResolution(mapPoint, 10);
    mapView.invalidate();


   } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  }
  else
  {

   System.out.println("else of spinner selection");

   try 
   {    
    int count = 0;
    int temp = 1;
    for (int i = 0; i < footprintdata.size(); i++) {

     if (footprintdata.get(i).getLocationtype()
       .equalsIgnoreCase(spinner.getSelectedItem().toString())) {

      count++;
     }
    }

    System.out.println("count :"+ count);
    Graphic[] resultGraphics = new Graphic[count];
    Envelope extent = new Envelope(); 

    for (int i = 0; i < footprintdata.size(); i++) {

     //PictureMarkerSymbol imagesymbol = null;
     if (footprintdata.get(i).getLocationtype()
       .equalsIgnoreCase(spinner.getSelectedItem().toString())) {

      System.out.println("result success : "
        + footprintdata.get(i).getLocationtype());

      double lattitude = Double
      .parseDouble(footprintdata.get(i)
        .getLatitude());
      double longitude = Double
      .parseDouble(footprintdata.get(i) 
        .getLongitude());

      mLocation = new Point(XCoordinateFromLongitude(longitude), YCoordinateFromLatitude(lattitude));

      mapPoint = (Point) GeometryEngine.project(mLocation,
        SpatialReference.create(4326),mapView.getSpatialReference());

      SimpleMarkerSymbol resultSymbol = new SimpleMarkerSymbol(Color.GREEN, 20, SimpleMarkerSymbol.STYLE.DIAMOND);

      //PictureMarkerSymbol imagesymbolicon = new PictureMarkerSymbol(imagemarker(i));
      Graphic resultLocation = new Graphic(mapPoint,resultSymbol);

      System.out.println("temp :"+ temp);
      resultGraphics[temp] = resultLocation;
      extent.merge(mapPoint);
      temp++;

     }
    }

    graphicsLayer.addGraphics(resultGraphics);
    mapView.setExtent(extent, 100);
    mapView.zoomToResolution(mapPoint, 10);
    mapView.invalidate();    

   } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  }
 }


public double YCoordinateFromLatitude(double latitude)
    {
        double rad = latitude * 0.0174532;
        double fsin = Math.sin(rad);
        double y = 6378137 / 2.0 * Math.log((1.0 + fsin) / (1.0 - fsin));

        return y;
    }   

    public double XCoordinateFromLongitude(double longitude)
    {
        double x = longitude * 0.017453292519943 * 6378137;
        return x;
    }

此代码第一次运行良好。但之后我在我的 Logcat 中得到了MapCore(24187): Failed to generate sequences for graphic。 如果有人对此有任何想法,请提供帮助。

【问题讨论】:

    标签: android esri


    【解决方案1】:

    我通过删除这两种方法解决了这个问题:-

    public double YCoordinateFromLatitude(double latitude)
        {
            double rad = latitude * 0.0174532;
            double fsin = Math.sin(rad);
            double y = 6378137 / 2.0 * Math.log((1.0 + fsin) / (1.0 - fsin));
    
            return y;
        }   
    
        public double XCoordinateFromLongitude(double longitude)
        {
            double x = longitude * 0.017453292519943 * 6378137;
            return x;
        }
    

    这两种方法在 IOS 上运行良好,但对于 Android,我使用以下行

    mLocation = new Point(longitude,lattitude);
    

    而不是这个

    mLocation = new Point(XCoordinateFromLongitude(longitude), YCoordinateFromLatitude(lattitude));
    

    这解决了我的问题。

    【讨论】:

      猜你喜欢
      • 2013-11-17
      • 2017-11-29
      • 2015-10-16
      • 1970-01-01
      • 2020-10-23
      • 2021-05-07
      • 1970-01-01
      • 2018-08-26
      • 2020-11-25
      相关资源
      最近更新 更多