<commit_before>/**
 * Copyright 2015, GeoSolutions Sas.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

var React = require('react');
var L = require('leaflet');
var assign = require('object-assign');
require('leaflet.locatecontrol')();
require('leaflet.locatecontrol/dist/L.Control.Locate.css');

L.Control.MSLocate = L.Control.Locate.extend({
    setMap: function(map) {
        this._map = map;
        this._layer = this.options.layer;
        this._layer.addTo(map);
        this._event = undefined;

            // extend the follow marker style and circle from the normal style
        let tmp = {};
        L.extend(tmp, this.options.markerStyle, this.options.followMarkerStyle);
        this.options.followMarkerStyle = tmp;
        tmp = {};
        L.extend(tmp, this.options.circleStyle, this.options.followCircleStyle);
        this.options.followCircleStyle = tmp;
        this._resetVariables();
        this.bindEvents(map);
    },
    _setClasses: function(state) {
        return state;
    },
    _cleanClasses: function() {
        return null;
    },
    setStrings: function(newStrings) {
        this.options.strings = assign({}, this.options.strings, newStrings);
    }
});

let Locate = React.createClass({
    propTypes: {
        map: React.PropTypes.object,
        status: React.PropTypes.bool,
        messages: React.PropTypes.object
    },
    getDefaultProps() {
        return {
            id: 'overview',
            status: false
        };
    },
    componentDidMount() {
        if (this.props.map ) {
            this.locate = new L.Control.MSLocate(this.defaultOpt);
            this.locate.setMap(this.props.map);
        }
        if (this.props.status) {
            this.locate.start();
        }
    },
    componentWillReceiveProps(newProps) {
        if (newProps.status !== this.props.status && newProps.status) {
            this.locate.start();
        }else if (newProps.status !== this.props.status && !newProps.status) {
            this.locate.stop();
        }
        if (newProps.messages !== this.props.messages) {
            this.locate.setStrings(newProps.messages);
            this.locate.stop();
            this.locate.start();
        }
    },
    render() {
        return null;
    },
    defaultOpt: { // For all configuration options refer to https://github.com/Norkart/Leaflet-MiniMap
            follow: true,  // follow with zoom and pan the user's location
            remainActive: true,
            locateOptions: {
                maximumAge: 2000,
                enableHighAccuracy: false,
                timeout: 10000,
                maxZoom: Infinity,
                watch: true  // if you overwrite this, visualization cannot be updated
                }
            }
});

module.exports = Locate;
<commit_msg>Fixes #292<commit_after>/**
 * Copyright 2015, GeoSolutions Sas.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

var React = require('react');
var L = require('leaflet');
var assign = require('object-assign');
require('leaflet.locatecontrol')();
require('leaflet.locatecontrol/dist/L.Control.Locate.css');

L.Control.MSLocate = L.Control.Locate.extend({
    setMap: function(map) {
        this._map = map;
        this._layer = this.options.layer;
        this._layer.addTo(map);
        this._event = undefined;

            // extend the follow marker style and circle from the normal style
        let tmp = {};
        L.extend(tmp, this.options.markerStyle, this.options.followMarkerStyle);
        this.options.followMarkerStyle = tmp;
        tmp = {};
        L.extend(tmp, this.options.circleStyle, this.options.followCircleStyle);
        this.options.followCircleStyle = tmp;
        this._resetVariables();
        this.bindEvents(map);
    },
    _setClasses: function(state) {
        return state;
    },
    _cleanClasses: function() {
        return null;
    },
    setStrings: function(newStrings) {
        this.options.strings = assign({}, this.options.strings, newStrings);
    }
});

let Locate = React.createClass({
    propTypes: {
        map: React.PropTypes.object,
        status: React.PropTypes.bool,
        messages: React.PropTypes.object
    },
    getDefaultProps() {
        return {
            id: 'overview',
            status: false
        };
    },
    componentDidMount() {
        if (this.props.map ) {
            this.locate = new L.Control.MSLocate(this.defaultOpt);
            this.locate.setMap(this.props.map);
        }
        if (this.props.status) {
            this.locate.start();
        }
    },
    componentWillReceiveProps(newProps) {
        if (newProps.status !== this.props.status && newProps.status) {
            this.locate.start();
        }else if (newProps.status !== this.props.status && !newProps.status) {
            this.locate.stop();
        }
        if (newProps.messages !== this.props.messages) {
            this.locate.setStrings(newProps.messages);
            if (newProps.status) {
                this.locate.stop();
                this.locate.start();
            }
        }
    },
    render() {
        return null;
    },
    defaultOpt: { // For all configuration options refer to https://github.com/Norkart/Leaflet-MiniMap
            follow: true,  // follow with zoom and pan the user's location
            remainActive: true,
            locateOptions: {
                maximumAge: 2000,
                enableHighAccuracy: false,
                timeout: 10000,
                maxZoom: Infinity,
                watch: true  // if you overwrite this, visualization cannot be updated
                }
            }
});

module.exports = Locate;

{'fraction_non_alphanumeric': 0.1198641765704584, 'fraction_numerical': 0.004923599320882852, 'mean_word_length': 2.01021972406745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '7140829', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1642, 'n_words': 365}