/*
 This file is a part of libertysoil.org website
 Copyright (C) 2015  Loki Education (Social Enterprise)

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
import React, { PropTypes } from 'react';

import { MAPBOX_ACCESS_TOKEN } from '../config';

let Leaflet;

if (typeof (window) !== 'undefined') {
  Leaflet = require('react-leaflet');
}


export default class MapboxMap extends React.Component {
  static displayName = 'MapboxMap';

  static propTypes = {
    selectedLocation: PropTypes.shape({
      lat: PropTypes.number,
      lon: PropTypes.number
    }).isRequired,
    viewLocation: PropTypes.shape({
      lat: PropTypes.number,
      lon: PropTypes.number
    }).isRequired
  };

  render() {
    if (!Leaflet) {
      return null;
    }

    let {
      selectedLocation,
      viewLocation,
      ...props
    } = this.props;

    return (
      <Leaflet.Map
        center={viewLocation}
        ref={c => this.leafletMap = c}
        zoom={13}
        {...props}
      >
        <Leaflet.TileLayer
          attribution='<a href="https://www.mapbox.com/about/maps/" target="_blank">&copy; Mapbox &copy; OpenStreetMap</a> <a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a>'
          url={`http://api.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token=${MAPBOX_ACCESS_TOKEN}`}
        />
        <Leaflet.Marker position={selectedLocation} />
      </Leaflet.Map>
    );
  }
}

@@ -789,16 +789,50 @@
 'react';
+%0Aimport %7B isEmpty %7D from 'lodash';
 %0A%0Aimport
@@ -1087,16 +1087,77 @@
 pes = %7B%0A
+    frozen: PropTypes.bool,%0A    noWheelZoom: PropTypes.bool,%0A
     sele
@@ -1251,27 +1251,16 @@
 r%0A    %7D)
-.isRequired
 ,%0A    vi
@@ -1356,24 +1356,455 @@
   %7D)
-.isRequired%0A  %7D;
+%0A  %7D;%0A%0A  static defaultProps = %7B%0A    zoom: 13,%0A    frozen: false,%0A    noWheelZoom: false%0A  %7D;%0A%0A  componentDidMount() %7B%0A    let map = this.leafletMap.leafletElement;%0A%0A    if (this.props.frozen) %7B%0A      map.dragging.disable();%0A      map.touchZoom.disable();%0A      map.doubleClickZoom.disable();%0A      map.scrollWheelZoom.disable();%0A      map.keyboard.disable();%0A    %7D%0A%0A    if (this.props.noWheelZoom) %7B%0A      map.scrollWheelZoom.disable();%0A    %7D%0A  %7D
 %0A%0A  
@@ -2055,26 +2055,8 @@
  c%7D%0A
-        zoom=%7B13%7D%0A
     
@@ -2436,24 +2436,65 @@
 %0A        /%3E%0A
+        %7B!isEmpty(selectedLocation) &&%0A  
         %3CLea
@@ -2532,24 +2532,34 @@
 ocation%7D /%3E%0A
+        %7D%0A
       %3C/Leaf

Refactor MapboxMap component