<commit_before>'use strict';
angular.module('genie.eventsMap')
.directive('eventsMap', ['$window', 'StylesService', '$state', '$stateParams',
  function($window, StylesService, $state, $stateParams) {

  function link(scope, elem, attrs) {
    var mapOptions = {
      zoom: +$stateParams.zoom || +attrs.zoom || 10,
      styles: StylesService.dark,
      streetViewControl: false,
      mapTypeControl: false,
      zoomControlOptions: {
        position: google.maps.ControlPosition.TOP_LEFT
      },
    };

    var map = new google.maps.Map(elem[0], mapOptions);

    if ($stateParams.center && $stateParams.center.length) {
      var center = $stateParams.center.split(',');
      map.setCenter({lat: +center[0], lng: +center[1]}); // from url
    } else {
      map.setCenter({lat: 30.25, lng: -97.75}); // default: Austin
    }
    scope.inputs.zoom_level = mapOptions.zoom;
    scope.map = map;

    map.addListener('zoom_changed', function() {
      var newZoom = map.getZoom();
      console.log(newZoom, 'zoom');
      scope.inputs.zoom_level = newZoom;
      scope.$apply();
      // update url
      $state.go('app.events-map.show',
        { zoom: newZoom, center: scope.map.getCenter().toUrlValue() },
        { notify: false }
      );
    });

    map.addListener('bounds_changed', scope.getEventsInBounds);

    resizeMap(map, elem);
  }

  function resizeMap(map, elem) {
    var parent = $('#' + elem.parent()[0].id);
    var doResize = function doResize () {
      var parentMargins = parent.outerHeight(true) - parent.height();<commit_msg>auto trigger for show/hide heatmap<commit_after>'use strict';
angular.module('genie.eventsMap')
.directive('eventsMap', ['$window', 'StylesService', '$state', '$stateParams',
  function($window, StylesService, $state, $stateParams) {

  function link(scope, elem, attrs) {
    var mapOptions = {
      zoom: +$stateParams.zoom || +attrs.zoom || 10,
      styles: StylesService.dark,
      streetViewControl: false,
      mapTypeControl: false,
      zoomControlOptions: {
        position: google.maps.ControlPosition.TOP_LEFT
      },
    };

    var map = new google.maps.Map(elem[0], mapOptions);

    if ($stateParams.center && $stateParams.center.length) {
      var center = $stateParams.center.split(',');
      map.setCenter({lat: +center[0], lng: +center[1]}); // from url
    } else {
      map.setCenter({lat: 30.25, lng: -97.75}); // default: Austin
    }
    scope.inputs.zoom_level = mapOptions.zoom;
    scope.map = map;

    map.addListener('zoom_changed', function() {
      var newZoom = map.getZoom();
      console.log(newZoom, 'zoom');
      scope.inputs.zoom_level = newZoom;
      var TRIGGER = 11;
      // when zoomed in, auto-hide heatmap & show sources
      if (newZoom >= TRIGGER) {
        scope.features.heatmap = false;
        scope.features.sources = true;
      } else if (newZoom < TRIGGER) {
        scope.features.heatmap = true;
      }
      scope.$apply();
      // update url
      $state.go('app.events-map.show',
        { zoom: newZoom, center: scope.map.getCenter().toUrlValue() },
        { notify: false }
      );
    });

    map.addListener('bounds_changed', scope.getEventsInBounds);

    resizeMap(map, elem);
  }

  function resizeMap(map, elem) {
    var parent = $('#' + elem.parent()[0].id);
    var doResize = function doResize () {
      var parentMargins = parent.outerHeight(true) - parent.height();
{'fraction_non_alphanumeric': 0.1581408944752996, 'fraction_numerical': 0.008769365682548963, 'mean_word_length': 2.933333333333333, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1564146', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1071, 'n_words': 218}