1、拿到标准的GeoJson数据。
{
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"geometry":{
"type":"MultiPolygon",
"coordinates":Array[1]
},
"properties":{
"Id":0,
"项目名":"XXXXXXX"
},
"id":"XXXXX_2000_37.9"
}
]
}
2、添加图层
import GeoJSONLayer from "@arcgis/core/layers/GeoJSONLayer.js";
const url = 'http://192.168.40.11:9080/file/geojson.json';
const renderer = {
type: 'simple',
symbol: {
type: 'simple-fill',
color: [226, 119, 40, 0.4],
outline: {
width: '3px',
color: 'red',
style: 'dash-dot',
},
},
};
const geojsonLayer = new GeoJSONLayer({
url: url,
copyright: 'USGS Earthquakes',
renderer: renderer,
popupTemplate: {
title: '弹窗',
outFields: ['*'],
content: '{项目名}'
},
});
1.边线样式
| Value | Description |
|---|
| dash |  |
| dash-dot |  |
| dot |  |
| long-dash |  |
| long-dash-dot |  |
| long-dash-dot-dot |  |
| none | The line has no symbol. |
| short-dash |  |
| short-dash-dot |  |
| short-dash-dot-dot |  |
| short-dot |  |
| solid |  |
3、设置图层注记
var labelClass = new LabelClass({
labelExpressionInfo: { expression: '$feature.项目名' },
labelPlacement: 'center-right',
symbol: {
type: 'text',
color: 'black',
haloSize: 1,
haloColor: 'white',
font: {
family: 'sans-serif',
size: 12,
weight: 'bold',
},
},
});
1、geojsonLayer.labelingInfo = [labelClass]
2、在创建GeoJSONLayer时,在属性中添加labelingInfo: [labelClass]