<commit_before>'use strict';

var React = require('react'),
    L = require('leaflet'),
    _ = require('lodash'),
    $ = jQuery;

var MapView = React.createClass({
  layers: {},
  houseIcon: null,

  createMap: function(element) {
    this.houseIcon = new L.Icon({
      
        shadowUrl: 'images/leaflet/house-shadow.png',
        iconUrl: 'images/leaflet/house-2x.png',
        iconSize:     [25, 40],
        shadowSize:   [39, 24],
        iconAnchor:   [12, 40],
        shadowAnchor: [10, 24],
        popupAnchor:  [0, 0]
    });

    this.map = L.map(element);
      L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
          attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
      }).addTo(this.map);
      L.marker([this.props.map.lat, this.props.map.lon], {icon: this.houseIcon}).addTo(this.map);
    return this.map;
  },

  componentDidMount: function() {
    L.Icon.Default.imagePath = 'images/leaflet';
    this.createMap(this.getDOMNode());
    this.setupMap();
    this.prepareLayers();
  },
  
  componentWillUnmount: function() {
    this.map = null;
  },

  setupMap: function () {
    if (typeof this.props.map === 'undefined') {
      return;
    }
    this.map.setView([this.props.map.lat, this.props.map.lon], this.props.map.zoom);
  },

  showLayer: function(serviceType) {
    /* clear old layers */
    _.each(this.layers, function(layer) {
      this.map.removeLayer(layer);
    }.bind(this));

    var serviceLayer = this.layers[serviceType];
    serviceLayer.addTo(this.map);

    /* calculate new bounds for map */
    var points = _.map(serviceLayer.getLayers(), function(layer) {
      return layer.getLatLng();
    });
    points.push(L.latLng(this.props.map.lat, this.props.map.lon));
    var bounds = new L.LatLngBounds(points);
    this.map.fitBounds(bounds);
  },
<commit_msg>clean up map code<commit_after>'use strict';

var React = require('react'),
    L = require('leaflet'),
    _ = require('lodash'),
    $ = jQuery;

var MapView = React.createClass({
  layers: {},
  houseIcon: null,

  createMap: function(element) {
    this.houseIcon = new L.Icon({
        shadowUrl: 'images/leaflet/house-shadow.png',
        iconUrl: 'images/leaflet/house-2x.png',
        iconSize:     [25, 40],
        shadowSize:   [39, 24],
        iconAnchor:   [12, 40],
        shadowAnchor: [10, 24],
        popupAnchor:  [0, 0]
    });

    this.map = L.map(element, {
      center: [this.props.map.lat, this.props.map.lon],
      zoom: this.props.map.zoom
    });
    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
      attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(this.map);
    L.marker([this.props.map.lat, this.props.map.lon], {icon: this.houseIcon}).addTo(this.map);
    return this.map;
  },

  componentDidMount: function() {
    L.Icon.Default.imagePath = 'images/leaflet';
    this.createMap(this.getDOMNode());
    this.prepareLayers();
  },
  
  componentWillUnmount: function() {
    this.map = null;
  },

  showLayer: function(serviceType) {
    /* clear old layers */
    _.each(this.layers, function(layer) {
      this.map.removeLayer(layer);
    }.bind(this));

    var serviceLayer = this.layers[serviceType];
    serviceLayer.addTo(this.map);

    /* calculate new bounds for map */
    var points = _.map(serviceLayer.getLayers(), function(layer) {
      return layer.getLatLng();
    });
    points.push(L.latLng(this.props.map.lat, this.props.map.lon));
    var bounds = new L.LatLngBounds(points);
    this.map.fitBounds(bounds);
  },

{'fraction_non_alphanumeric': 0.1753120665742025, 'fraction_numerical': 0.010540915395284327, 'mean_word_length': 2.823966065747614, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1756347', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1230, 'n_words': 209}