Добавить в листовку карту рынка геойсон - PullRequest
0 голосов
/ 22 апреля 2019

Где я ошибаюсь при добавлении маркера из геойсона?

Создать геойсон:

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)
}
...