<commit_before>export default class Map {

  constructor(container) {

    this.container = container || document.getElementById('map')
    this.map  = L.map(this.container, {attributionControl: false})

    // defaulting location to Stanley Park if geolocation fails
    this.lat = this.container.dataset.lat || 49.3019608
    this.lng = this.container.dataset.lng || -123.1507388

    // marker containers
    this.markers = []
    this.currentMarker = null
    this.previousMarker = null
  }

  init() {
    const apiToken = "<KEY>"

    this.map.setView([this.lat, this.lng], 13);

    const layer = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=' + apiToken, {
      maxZoom: 18,
      minZoom: 3,
      id:      'mapbox.streets'
    })
    this.map.addControl(layer)
  }

  loadMarkers() {
    const markers_json = JSON.parse(this.container.dataset.markers)

    // no markers to show, centering map on current location
    if (markers_json.length == 0) {
      this.geolocate()
      return false
    }

    let iconDefault = this._getIcon()
    for (let [index, marker_json] of markers_json.entries()) {

      // selecting icon
      let icon = iconDefault
      if(marker_json.is_current){
        icon = this._getIcon('yellow')
      } else if (index == 0) {
        icon = this._getIcon('green')
      } else if (markers_json.length - 1 == index) {
        icon = this._getIcon('red')
      }

      // putting marker on map
      let marker = L.marker([marker_json.lat, marker_json.lng], {
        icon:   icon,
        title:  marker_json.title
      })
      marker.bindPopup("<a href='" + marker_json.url + "'>"+ marker_json.title +"</a>")
      marker.addEventListener('click', (m) => {
        this.map.setView(m.latlng, 13)
      })
      marker.addTo(this.map)

      // registering markers for the map
      this.markers.push(marker)
      if(marker_json.is_current){
        this.currentMarker = marker
        marker.openPopup()
      }
      if(marker_json.is_previous){ this.previousMarker = marker }
    }
  }

  centerMarkers(){
    let markers = []
    if(this.currentMarker){markers.push(this.currentMarker)}
    if(this.previousMarker){markers.push(this.previousMarker)}
    if(markers.length == 0){markers = this.markers}
    let group = new L.featureGroup(markers)
    this.map.fitBounds(group.getBounds(), {maxZoom: 13, padding: [30, 30]})
  }

  addCrosshair() {
    let marker = L.marker(this.map.getCenter(), {
      icon: this._getIcon('yellow'),
      clickable: false}
    )
    marker.addTo(this.map)

    this.map.on('move', (e) => {
      marker.setLatLng(this.map.getCenter())
    })<commit_msg>zooming on click sucks<commit_after>export default class Map {

  constructor(container) {

    this.container = container || document.getElementById('map')
    this.map  = L.map(this.container, {attributionControl: false})

    // defaulting location to Stanley Park if geolocation fails
    this.lat = this.container.dataset.lat || 49.3019608
    this.lng = this.container.dataset.lng || -123.1507388

    // marker containers
    this.markers = []
    this.currentMarker = null
    this.previousMarker = null
  }

  init() {
    const apiToken = "pk.eyJ1IjoiZ3JvY2VyeSIsImEiOiJjajA1cTZjdzQwNWR5Mndwa2dqM2l3ZnI4In0.MoTpE4qEHYKKYyOcfhd1Rg"

    this.map.setView([this.lat, this.lng], 13);

    const layer = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=' + apiToken, {
      maxZoom: 18,
      minZoom: 3,
      id:      'mapbox.streets'
    })
    this.map.addControl(layer)
  }

  loadMarkers() {
    const markers_json = JSON.parse(this.container.dataset.markers)

    // no markers to show, centering map on current location
    if (markers_json.length == 0) {
      this.geolocate()
      return false
    }

    let iconDefault = this._getIcon()
    for (let [index, marker_json] of markers_json.entries()) {

      // selecting icon
      let icon = iconDefault
      if(marker_json.is_current){
        icon = this._getIcon('yellow')
      } else if (index == 0) {
        icon = this._getIcon('green')
      } else if (markers_json.length - 1 == index) {
        icon = this._getIcon('red')
      }

      // putting marker on map
      let marker = L.marker([marker_json.lat, marker_json.lng], {
        icon:   icon,
        title:  marker_json.title
      })
      marker.bindPopup("<a href='" + marker_json.url + "'>"+ marker_json.title +"</a>")
      marker.addTo(this.map)

      // registering markers for the map
      this.markers.push(marker)
      if(marker_json.is_current){
        this.currentMarker = marker
        marker.openPopup()
      }
      if(marker_json.is_previous){ this.previousMarker = marker }
    }
  }

  centerMarkers(){
    let markers = []
    if(this.currentMarker){markers.push(this.currentMarker)}
    if(this.previousMarker){markers.push(this.previousMarker)}
    if(markers.length == 0){markers = this.markers}
    let group = new L.featureGroup(markers)
    this.map.fitBounds(group.getBounds(), {maxZoom: 13, padding: [30, 30]})
  }

  addCrosshair() {
    let marker = L.marker(this.map.getCenter(), {
      icon: this._getIcon('yellow'),
      clickable: false}
    )
    marker.addTo(this.map)

    this.map.on('move', (e) => {
      marker.setLatLng(this.map.getCenter())
    })
{'fraction_non_alphanumeric': 0.14047574452144596, 'fraction_numerical': 0.01573328338640195, 'mean_word_length': 2.6853002070393375, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, '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': '1421359', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1762, 'n_words': 329}