根据属性值更改ESRI要素图层中标记的图标

时间:2018-07-03 08:29:50

标签: android esri esri-maps

我有一个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)));

这不起作用,我们非常感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

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

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

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