从geojson添加标记时我在哪里弄错了?
创建geojson:
coorsField: {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Point',
'coordinates': [
37.514190673828125,
55.7717454171889
] } } ] }
并创建用于向传单添加标记的功能:
createGeojsonLayer() {
function onEachFeature(feature, layer) {
var popupContent = '<p>I started out as a GeoJSON</p>'
layer.bindPopup(popupContent)
}
this.jsonLayer = new L.LayerGroup()
this.jsonLayer = L.geoJSON(this.coorsField, {
pointToLayer: function(feature, latlng) {
return L.marker(latlng, { icon: this.iconAlarm })
},
onEachFeature: onEachFeature
}).addTo(this.map)
this.map.addLayer(this.jsonLayer)
}