代码之家  ›  专栏  ›  技术社区  ›  Jose Raul Velasquez

如何使用图形功能集设置功能层Android Arcgis

  •  -1
  • Jose Raul Velasquez  · 技术社区  · 8 年前

    我试图用图形填充功能层,但有一个问题,即当使用FeatureLayer(graphics[])时,指令不会将图形添加到功能层。它显示了以下内容

    Error "method invocation may produce java.lang.nullpointerexception 
    

    我尝试为列表级别代码指定一个值,但不会生成任何错误,图形列表已正确填充,或者知道如何使用图形列表填充要素层?

    我附上了我的代码

    MapView mMapView;
    ArcGISFeatureLayer featurelayerpoints;
    FeatureSet variablefeatureset = null;
    Graphic[] graficos = new Graphic[listcount];
    
    for (int i = 0; i < listcount; i++) {
        Point wgspoint = new Point(routesinfolist[i].Longitude, routesinfolist[i].Latitude);
        Point mapPoint = (Point) GeometryEngine.project(wgspoint, SpatialReference.create(4326),
            mMapView.getSpatialReference());
        Unit mapUnit = mMapView.getSpatialReference().getUnit();
        double zoomWidth = Unit.convertUnits(SEARCH_RADIUS, Unit.create(LinearUnit.Code.MILE_US), mapUnit);
    
        attributes.put(String.valueOf(routesinfolist[i].IDOrder), "IDOrder");
        graficos[i] = new Graphic(mapPoint, new PictureMarkerSymbol(getResources().getDrawable(R.drawable.circler)), attributes, i);
    }
    
    variablefeatureset.setGraphics(graficos);
    featurelayerpoints = new ArcGISFeatureLayer(null, variablefeatureset, null);
    mMapView.addLayer(featurelayerpoints, 1);
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Debosmit Ray    8 年前

    目前,您的 FeatureSet variablefeatureset 设置为 null 。需要使用提供的构造函数初始化它。[ docs ]

    FeatureSet variablefeatureset = new FeatureSet();