之前做arcgis.js开发的时候 一直使用的是TextSymbol + SimpleMarkerSymbol实现的 也就是一条数据打两个点(一个坐标点 一个文本点) 这种操作实在非常鸡肋;学会了FeatureLayer之后发现实现该功能非常简单
const LayerView = new FeatureLayer({
source: [
new Graphic({
geometry: new Point(12914838.35, 4814529.9, new SpatialReference({ wkid: 3857 })),
attributes: {
name: '濉溪县管网监测站#2',
id: '666'
}
})
],
renderer: {
type: 'simple',
symbol: {
type: 'picture-marker',
url: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/dir-via-marker.png',
width: '40px',
height: '40px'
}
},
geometryType: 'point',
fields: [
{
name: 'id',
alias: 'ObjectID',
type: 'oid'
},
{
name: 'name',
alias: 'name',
type: 'string'
}
],
labelingInfo: [
new LabelClass({
labelExpressionInfo: { expression: '$feature.NAME' },
labelPlacement: 'above-center',
symbol: {
type: 'text',
color: '#f00',
haloSize: 2,
haloColor: 'white',
yoffset: -3
}
})
],
objectIdField: 'ObjectID'
})
window.customMap.map.add(LayerView)
标签:40px,js4,name,ObjectID,FeatureLayer,---,new,type
From: https://blog.csdn.net/QDxin_xyz/article/details/145092750