<commit_before>// Leaflet map rendering functions

var leaflet_tools = new function() {
	/*
	 * Add a set of markers to the map. Markers are defined as an array of json hashes. Each
	 * JSON hash has values latitude, longitude, iconClass, popupText, open
	 */
	var LMmarkers = new Array();
	var LMcircles = new Array();
	var LMpolylines = new Array();
	var LMmap;
	var LMbounds;
	var LMcurrent_popup;

	var OPENSTREETMAP_URL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
	var OPENSTREETMAP_ATTRIB = 'Map data © OpenStreetMap contributors';

	var MAPBOX_URL = 'http://{s}.tiles.mapbox.com/v4/%map_key%/{z}/{x}/{y}.png?access_token=%access_token%';

  this.markers = function() {
		return LMmarkers;
	}
	this.map = function() {
		return LMmap;
	}
	this.map_bounds = function() {
		return LMbounds;
	}
	this.current_popup = function() {
		return LMcurrent_popup;
	}
	/*
	 * Must be called first. Pass the Id of the div containing the map and any options
	 * that should be passed to the map constructor
	 */
	this.init = function(mapId, options) {
		LMmap = L.map(mapId);
		//Console.log(options);
		//alert(options.min_zoom);
		//alert(options.max_zoom);
		if (options.tile_provider == 'OPENSTREETMAP') {
			var mapUrl = OPENSTREETMAP_URL;
			var mapAttrib = OPENSTREETMAP_ATTRIB;
			L.tileLayer(mapUrl, {minZoom: options.min_zoom, maxZoom: options.max_zoom, attribution: mapAttrib}).addTo(LMmap);
		} else if (options.tile_provider == 'MAPBOX') {
			var mapUrl = MAPBOX_URL.replace("%map_key%", options.map_key).replace("%access_token%", options.access_token);
			//Console.log(mapURL);
			L.tileLayer(mapUrl, {zoomControl: false, detectRetina: true}).addTo(LMmap);
		} else {
			var googleLayer = new L.Google('ROADMAP');
	    LMmap.addLayer(googleLayer);
		}
		// install a popup listener
		LMmap.on('popupopen', function(event){
			//alert('popup opened');
			LMcurrent_popup = event.popup;
		});
	};
	/*
	 * Adds a click handler to the map
	 */
	this.add_click_handler = function(event, handler) {
		LMmap.on(event, handler);
	};
	/*
	 * Removes a click handler from the map
	 */
	this.remove_click_handler = function(event, handler) {
		LMmap.off(event, handler);
	};
	/**
	 *
	 * Centers the map on a specified marker without changing the zoom level
	 */
	this.center_on_marker = function(markerId) {
		var marker = find_marker_by_id(markerId);
		if (marker) {
			var latlng = marker.getLatLng();
			this.pan_to(latlng.lat, latlng.lng);
		}
	};
	/*
	 * Pans the map to a gven coordinate without changing the zoom level
	 */
	this.pan_to = function(lat, lng) {
		var latlng = new L.LatLng(lat, lng);
		LMmap.panTo(latlng);
	};
	/*
	 * Called last after the map has been configured.
	 */
	this.show_map = function() {
		// Add the markers to the map
		for (var i=0;i<LMmarkers.length;i++) {
			LMmap.addLayer(LMmarkers[i]);
		}
		// Add the circles to the map<commit_msg>Fix bug in leaflet JS<commit_after>// Leaflet map rendering functions

var leaflet_tools = new function() {
	/*
	 * Add a set of markers to the map. Markers are defined as an array of json hashes. Each
	 * JSON hash has values latitude, longitude, iconClass, popupText, open
	 */
	var LMmarkers = new Array();
	var LMcircles = new Array();
	var LMpolylines = new Array();
	var LMmap;
	var LMbounds;
	var LMcurrent_popup;

	var OPENSTREETMAP_URL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
	var OPENSTREETMAP_ATTRIB = 'Map data © OpenStreetMap contributors';

	var MAPBOX_URL = 'http://{s}.tiles.mapbox.com/v4/%map_key%/{z}/{x}/{y}.png?access_token=%access_token%';

  this.markers = function() {
		return LMmarkers;
	}
	this.map = function() {
		return LMmap;
	}
	this.map_bounds = function() {
		return LMbounds;
	}
	this.current_popup = function() {
		return LMcurrent_popup;
	}
	/*
	 * Must be called first. Pass the Id of the div containing the map and any options
	 * that should be passed to the map constructor
	 */
	this.init = function(mapId, options) {
		LMmap = L.map(mapId);
		//Console.log(options);
		//alert(options.min_zoom);
		//alert(options.max_zoom);
		if (options.tile_provider == 'OPENSTREETMAP') {
			var mapUrl = OPENSTREETMAP_URL;
			var mapAttrib = OPENSTREETMAP_ATTRIB;
			L.tileLayer(mapUrl, {minZoom: options.min_zoom, maxZoom: options.max_zoom, attribution: mapAttrib}).addTo(LMmap);
		} else if (options.tile_provider == 'MAPBOX') {
			var mapUrl = MAPBOX_URL.replace("%map_key%", options.map_key).replace("%access_token%", options.access_token);
			//Console.log(mapURL);
			L.tileLayer(mapUrl, {zoomControl: false, detectRetina: true}).addTo(LMmap);
		} else {
			var googleLayer = new L.Google('ROADMAP');
	    LMmap.addLayer(googleLayer);
		}
		// install a popup listener
		LMmap.on('popupopen', function(event){
			//alert('popup opened');
			LMcurrent_popup = event.popup;
		});
	};
	/*
	 * Adds a click handler to the map
	 */
	this.add_click_handler = function(event, handler) {
		LMmap.on(event, handler);
	};
	/*
	 * Removes a click handler from the map
	 */
	this.remove_click_handler = function(event, handler) {
		LMmap.off(event, handler);
	};
	/**
	 *
	 * Centers the map on a specified marker without changing the zoom level
	 */
	this.center_on_marker = function(markerId) {
		var marker = this.find_marker_by_id(markerId);
		if (marker) {
			var latlng = marker.getLatLng();
			this.pan_to(latlng.lat, latlng.lng);
		}
	};
	/*
	 * Pans the map to a gven coordinate without changing the zoom level
	 */
	this.pan_to = function(lat, lng) {
		var latlng = new L.LatLng(lat, lng);
		LMmap.panTo(latlng);
	};
	/*
	 * Called last after the map has been configured.
	 */
	this.show_map = function() {
		// Add the markers to the map
		for (var i=0;i<LMmarkers.length;i++) {
			LMmap.addLayer(LMmarkers[i]);
		}
		// Add the circles to the map
{'fraction_non_alphanumeric': 0.13791313376016612, 'fraction_numerical': 0.0006921612735767433, 'mean_word_length': 3.7454844006568146, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '521910', 'n_tokens_mistral': 2214, 'n_tokens_neox': 2023, 'n_words': 517}