绘制geojson
2021-04-30 本文已影响0人
Amy_yqh
toLatLng(coords) {
return L.CRS.EPSG3857.unproject(L.point(coords))
},
onEachFeature(feature, layer) {
layer.on({
// mouseover: (d) => {
// debugger
// },
// mouseout: () => {
// debugger
// },
click: () => {
if (currentCityLayer) {
currentCityLayer.setStyle(defaultCityStyle)
}
if (currentCityLayer === layer) {
return
}
layer.setStyle(selectCityStyle)
currentCityLayer = layer
},
})
},
drawArea(data) {
const options = {
onEachFeature: this.onEachFeature,
style: {
fillColor: '#ff0000',
weight: 2,
opacity: 0.8,
color: 'white',
dashArray: '3',
fillOpacity: 0.8
},
coordsToLatLng: this.toLatLng
}
let layer = L.geoJson(data, options)
layer.addTo(map)
},