<commit_before>class @MapLayer
  constructor: ->
    @handleOptions()
    @setupLoadEvents()

  setupLoadEvents: =>
    @layer.on 'loading', (e) =>
      $("##{@config.slug}").spin('layer')

    @layer.on 'load', (e) =>
      $("##{@config.slug}").spin(false)

  handleOptions: =>
    for option,active of @config.options
      if @["option_#{option}"]?
        @["option_#{option}"](active)

  @fromConfig: (map, config) ->
    switch config.type
      when 'wms'
        layer = new WMSLayer(map, config)
      when 'geojson'
        layer = new GeoJSONLayer(map, config)

  option_auto_zoom: =>
    @layer.on 'ready', =>
      if @config.options? and @config.options.auto_zoom == 'yes'
        @map.whenReady =>
          setTimeout =>
            bounds = @layer.getBounds()
            @map.fitBounds(bounds) if bounds.isValid()
          , 100

  addTo: (map, zIndex = 100) =>
    map.addLayer(@layer)
    @layer.setZIndex(zIndex)

    if @config.options? and @config.options.baselayer != 'yes'
      @layer.bringToFront()

  removeFrom: (map, control) =>
    map.removeLayer(@layer)<commit_msg>autozoom layer when activated instead of initialize<commit_after>class @MapLayer
  constructor: ->
    @handleOptions()
    @setupLoadEvents()

  setupLoadEvents: =>
    @layer.on 'loading', (e) =>
      $("##{@config.slug}").spin('layer')

    @layer.on 'load', (e) =>
      $("##{@config.slug}").spin(false)

  handleOptions: =>
    for option,active of @config.options
      if @["option_#{option}"]?
        @["option_#{option}"](active)

  @fromConfig: (map, config) ->
    switch config.type
      when 'wms'
        layer = new WMSLayer(map, config)
      when 'geojson'
        layer = new GeoJSONLayer(map, config)

  option_auto_zoom: =>
    @layer.on 'ready', =>

  addTo: (map, zIndex = 100) =>
    map.addLayer(@layer)
    @layer.setZIndex(zIndex)

    if @config.options?
      if @config.options.auto_zoom == 'yes'
        @map.whenReady =>
          setTimeout =>
            bounds = @layer.getBounds()
            @map.fitBounds(bounds) if bounds.isValid()
          , 100

      if @config.options.baselayer != 'yes'
        @layer.bringToFront()

  removeFrom: (map, control) =>
    map.removeLayer(@layer)
{'fraction_non_alphanumeric': 0.16659182757072294, 'fraction_numerical': 0.005388414907947912, 'mean_word_length': 2.658456486042693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '3421764', 'n_tokens_mistral': 760, 'n_tokens_neox': 735, 'n_words': 145}