src/Map/MainMap.js
// Adds geojson layer to map, while giving it required features and class name
Adds geojson layer to map, while giving it required features and class name
Adds geojson layer to map while giving it required features and class name
addGeoJSONLayer(geojson, key) {
    const geojsonLayer = L.geoJson(geojson, {
      onEachFeature: this.onEachFeature,
    });
    if (this.state.geojson_key !== null) {
      geojsonLayer.setStyle({'className': 'map-path '+this.state.geojson_key}); 
    } else {
      geojsonLayer.setStyle({'className': 'map-path'}); 
    }
    geojsonLayer.addTo(this.state.map);
    if ('_northEast' in geojsonLayer.getBounds()){
      this.state.map.fitBounds(geojsonLayer.getBounds())
    }
    this.setState({ geojsonLayer });
   }
addGeoJSONLayer ( geojson , key ) { const geojsonLayer = L . geoJson ( geojson , { onEachFeature : this . onEachFeature , } ) ; if ( this . state . geojson_key !== null ) { geojsonLayer . setStyle ( { 'className' : 'map-path ' + this . state . geojson_key } ) ; } else { geojsonLayer . setStyle ( { 'className' : 'map-path' } ) ; } geojsonLayer . addTo ( this . state . map ) ; if ( '_northEast' in geojsonLayer . getBounds ( ) ) { this . state . map . fitBounds ( geojsonLayer . getBounds ( ) ) } this . setState ( { geojsonLayer } ) ; }
Adds geojson layer to map, while giving it required features and class name
Adds geojson layer to map while giving it required features and class name
// add our GeoJSON layer to the Leaflet map object //will add key id to geojson layer. //will add the required class // store the Leaflet GeoJSON layer in our component state.