문제

I am using following code to add graphic layer in my ESRI map.

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;
    }

this code works fine at first time. but after it I am getting MapCore(24187): Failed to generate sequences for graphic in My Logcat. please help if some one have any idea about it.

도움이 되었습니까?

해결책

I solved this problem by removing these two methods :-

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;
    }

these two methods are working fine for IOS but for Android I used the following line

mLocation = new Point(longitude,lattitude);

instead of this

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

and this resolve my issue.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top