
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer'
import Graphic from '@arcgis/core/Graphic'
import SimpleMarkerSymbol from '@arcgis/core/symbols/SimpleMarkerSymbol'
import Polygon from '@arcgis/core/geometry/Polygon'
import anHui from '@/assets/json/anHui.json'
import * as geometryEngine from '@arcgis/core/geometry/geometryEngine'
window.customMap = mapInit.initMap()
const graphicsLayer = new GraphicsLayer()
const polygon = new Polygon({
rings: anHui.features[0].geometry.coordinates
})
const viewExtent = new Polygon({
rings: [
[-180, 90],
[180, 90],
[180, -90],
[-180, -90],
[-180, 90]
]
})
const outsidePolygon = geometryEngine.difference(viewExtent, polygon)
const graphic = new Graphic({
geometry: outsidePolygon,
symbol: {
type: 'simple-fill',
color: [0, 0, 0, 0.8],
outline: {
color: [255, 255, 255],
width: 1
}
}
})
graphicsLayer.add(graphic)
const outsideGraphic = new Graphic({
geometry: polygon,
symbol: {
type: 'simple-fill',
outline: {
color: [255, 255, 255, 1],
width: 1
}
}
})
graphicsLayer.add(outsideGraphic)
window.customMap.map.add(graphicsLayer)