通过添加graphic来实现,代码如下:
//data为需要高亮的要素信息
highLight = data => {
const { view } = this.props.mapView;
loadModules([ //react中加载arcgis的方式
'esri/Graphic',
], { css: true })
.then(([
Graphic,
]) => {
const items = view.graphics.items
if (items.length > 0) { //清除已存在的,默认一次只高亮一个
view.graphics.removeMany(items)
}
//自定义的高亮符号
const markerSymbol = {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
style: "square",
color: [51, 204, 51, 0], //r g b a
size: "24px", // pixels
outline: { // autocasts as new SimpleLineSymbol()
color: [0, 255, 255],
width: 2 // points
}
};
const selectedGraphic = new Graphic({
geometry: data.geometry,
symbol: markerSymbol
});
view.graphics.add(selectedGraphic);
})
}
效果如下: