0

我有一个 esri 要素图层,其中包含多个属性。

我需要根据属性值之一为其标记设置不同的图标,

是否可以根据某些编码为同一图层设置多个渲染器?

这就是我尝试过的

QueryParameters parameters = new QueryParameters();
    parameters.setWhere("1=1");
    parameters.setReturnGeometry(true);
    parameters.setOutFields(mHafilatLayerOptions.outFields);
    parameters.setOutSpatialReference(_mapView.getSpatialReference());

    try {
        QueryTask queryTask = new QueryTask(mHafilatLayer.getUrl(),Utilities.getUserCredentials());
        queryTask.execute(parameters, new CallbackListener<FeatureResult>() {
            @Override
            public void onCallback(FeatureResult objects) {
                for (Object currentElem : objects) {
                    if (currentElem instanceof Feature) {
                        Feature currentFeature = (Feature) currentElem;

                        Point point = GeometryEngine.project(((Point)currentFeature.getGeometry()).getX(),
                                ((Point)currentFeature.getGeometry()).getY(), _mapView.getSpatialReference());
                        String deviceType = (String) currentFeature.getAttributes().get("DEVICE");

                        switch (deviceType) {
                            case "TVM":
                                mHafilatLayer.addGraphic(new Graphic(point,Utilities.createPictureMarkerSymbol(getPointOfInterestIcon(AppConstants.LayerConstants.PARKING_HANDICAP, true),false)));
                                break;
                            case "BBR":
                                mHafilatLayer.addGraphic(new Graphic(point,Utilities.createPictureMarkerSymbol(getPointOfInterestIcon(AppConstants.LayerConstants.HafilatKiosks, true),false)));
                                break;
                            case "TOM":
                                mHafilatLayer.addGraphic(new Graphic(point,Utilities.createPictureMarkerSymbol(getPointOfInterestIcon(AppConstants.LayerConstants.HafilatKiosks, true),false)));
                                break;
                            default:
                                mHafilatLayer.addGraphic(new Graphic(point,Utilities.createPictureMarkerSymbol(getPointOfInterestIcon(AppConstants.LayerConstants.HafilatKiosks, true),false)));
                        }
                    }
                }
            }

            @Override
            public void onError(Throwable throwable) {

            }
        });
    } catch (EsriSecurityException e) {
        e.printStackTrace();
    } 
    mHafilatLayer.setRenderer(new SimpleRenderer(Utilities.createPictureMarkerSymbol(getPointOfInterestIcon(AppConstants.LayerConstants.HafilatKiosks, true), false)));

这不起作用,非常感谢任何帮助。

4

1 回答 1

1

根据属性值之一为其标记设置不同的图标 - 可以。

ArcGIS 可以选择基于要素图层中的属性进行渲染,例如:唯一值渲染器

查看链接:https ://developers.arcgis.com/android/latest/guide/symbols-and-renderers.htm#ESRI_SECTION1_93757B8F4FBF45CB8D0ED7DCCE53D929

于 2018-07-10T03:31:01.663 回答