通過添加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);
})
}
效果如下: