//创建一个图层
const layer = new FeatureLayer({
url: "http://xxx.xxx.xxx",
});
map.add(layer);
// 创建查询对象
const query = new Query({
where: "XXX like '%"+XXX+"%'", // 查询条件
outFields: ["*"], // 返回的属性字段
returnGeometry: true,
returnQueryGeometry: true
});
// 执行查询
layer.queryFeatures(query)
.then(function (result) {
// 获取查询到的要素
const features = result.features[0];
// 给bufferGraphic.geometry赋值
bufferGraphic.geometry = features.geometry;
//定位到高亮地点
view.goTo(features.geometry);
view.graphics.add(bufferGraphic);
// 更新图层
layer.refresh();
})
.catch(function (error) {
console.error("查询错误: ", error);
});
//这个就是样式了 官网里面API文档直接搜Graphic
const bufferGraphic = new Graphic({
symbol: {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
color: [173, 216, 230, 0.2],
outline: {
// autocasts as new SimpleLineSymbol()
color: [255, 255, 255],
width: 1
}
}
});