我有一个 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)));
这不起作用,非常感谢任何帮助。