要素信息如下:
需要添加的标签是MARKER ACTIVITY GROUP这一列的信息。
效果图如下:
可以看到是绿色的文字,绿色并且透明的点标记
1.创建底图
"esri/WebMap"
var map = new WebMap({
portalItem:{id:"372b7caa8fe340b0a6300df93ef18a7e"}
});
2.获取要素图层
"esri/layers/FeatureLayer"
var featureLayer = new FeatureLayer({
portalItem:{id:"6012738cd1c74582a5f98ea30ae9876f"},
renderer:{
type:"simple",
symbol:{
type:"simple-marker",
color:rgba(0,100,0,0.6),
size:3,
outline:{
color:[0,0,0,0.1],
0.5
}
},
labelingInfo:[labelClass]
}
});
var labelClass = {
symbol:{
type:"text",
color:"green",
haloColor:"black", //光环的颜色
font:{
family:"playfair-display",
size:12,
weight:"bold"
}
},
labelPlacement:"above-center",
labelExpressionInfo:{
expression:"$feature.MARKER_ACTIVITY_GROUP"
}
}
3.显示底图和图层信息
"esri/views/MapView"
var view = new MapView({
map:map,
container:"viewDiv",
center:[-116.9250, 34.2501],
zoom:14
});
4.另外新添了一个搜索框
"esri/widgets/Search"
view.ui.add(new Search({view:view}),"top-right");