<commit_before>BaseView   = require 'lib/base_view'
helpers    = require '../lib/helpers'
baseLayers = require '../lib/map_providers'

module.exports = class MapView extends BaseView

    template: require 'templates/map'
    className: 'masterClass'

    initialize: (options) ->
        super
        @listenTo @collection, 'reset add',  @addAllMarkers
        @markers = new L.MarkerClusterGroup
            disableClusteringAtZoom:    17
            removeOutsideVisibleBounds: false
            animateAddingMarkers:       true

    events: ->
        'click #validate': 'validateChange'


    afterRender: ->
        #define leaflet images folder
        L.Icon.Default.imagePath = 'leaflet-images'
        #define lngitude and latitude to add on a new photo
        @standbyLatlng = new L.latLng(null)
        #define Marker used to add photos on the map
        @standbyMarker = L.marker null,
            draggable: true
            icon: L.divIcon
                className:  'leaflet-marker-div'
                iconSize:   L.point 39, 45
                html:       '<i class="fa fa-crosshairs" style="font-size:3.8em"></i>'

        #map declaration
        @map = L.map this.$('#map')[0],
            center:     [46.8451, 2.4938]
            zoom:       6       # 6 = default zoom
            maxZoom:    17
            minZoom:    2
            layers:     baseLayers["Water color"] #default map background
            maxBounds:  L.latLngBounds [84.26, -170], [-59.888, 192.30]

        @map.on 'contextmenu', (e) =>
            # add marker where user rightclick
            @standbyMarker.setLatLng e.latlng
            @standbyMarker.addTo @map
            @standbyLatlng = e.latlng
            @standbyMarker.bindPopup @standbyLatlng.toString()
            @dispChoiceBox()

            @standbyMarker.on 'move', (e) =>
                #update position when user move cursor
                @standbyMarker.closePopup()
                @standbyLatlng = e.latlng

        @map.on 'click', ()=>
            # hide marker and box with photos
            @hide()

        overlays = # map checkables layers
            "Photos": @markers,

        #add control button on the map
        layerControl = L.control.layers baseLayers, overlays,
            position: 'bottomright'
        .addTo @map

    addAllMarkers: ->

        @collection.hasGPS().each (photo) =><commit_msg>ajout layer villes<commit_after>BaseView   = require 'lib/base_view'
helpers    = require '../lib/helpers'
baseLayers = require '../lib/map_providers'

module.exports = class MapView extends BaseView

    template: require 'templates/map'
    className: 'masterClass'

    initialize: (options) ->
        super
        @listenTo @collection, 'reset add',  @addAllMarkers
        @markers = new L.MarkerClusterGroup
            disableClusteringAtZoom:    17
            removeOutsideVisibleBounds: false
            animateAddingMarkers:       true

    events: ->
        'click #validate': 'validateChange'


    afterRender: ->
        #define leaflet images folder
        L.Icon.Default.imagePath = 'leaflet-images'
        #define lngitude and latitude to add on a new photo
        @standbyLatlng = new L.latLng(null)
        #define Marker used to add photos on the map
        @standbyMarker = L.marker null,
            draggable: true
            icon: L.divIcon
                className:  'leaflet-marker-div'
                iconSize:   L.point 39, 45
                html:       '<i class="fa fa-crosshairs" style="font-size:3.8em"></i>'

        #map declaration
        @map = L.map this.$('#map')[0],
            center:     [46.8451, 2.4938]
            zoom:       6       # 6 = default zoom
            maxZoom:    17
            minZoom:    2
            layers:     baseLayers["Water color"] #default map background
            maxBounds:  L.latLngBounds [84.26, -170], [-59.888, 192.30]

        @map.on 'contextmenu', (e) =>
            # add marker where user rightclick
            @standbyMarker.setLatLng e.latlng
            @standbyMarker.addTo @map
            @standbyLatlng = e.latlng
            @standbyMarker.bindPopup @standbyLatlng.toString()
            @dispChoiceBox()

            @standbyMarker.on 'move', (e) =>
                #update position when user move cursor
                @standbyMarker.closePopup()
                @standbyLatlng = e.latlng

        @map.on 'click', ()=>
            # hide marker and box with photos
            @hide()

        overlays = # map checkables layers
            "Photos": @markers
            "Ville" : L.tileLayer 'http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}',
                type: 'hyb'
                ext: 'png'
                attribution: 'Tiles by <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
                subdomains: '1234'
                opacity: 0.9

        layerControl = L.control.layers baseLayers, overlays, #add control button on the map
            position: 'bottomright'
        .addTo @map

    addAllMarkers: ->

        @collection.hasGPS().each (photo) =>
{'fraction_non_alphanumeric': 0.10610806577916992, 'fraction_numerical': 0.01820673453406421, 'mean_word_length': 1.7721106890938687, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '4198002', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1460, 'n_words': 372}