<commit_before>var Gmaps4Rails = {
	//map config
	map: null,									// contains the map we're working on
	visibleInfoWindow: null,
  
	//Map settings
	map_options: {
	  id: 'gmaps4rails_map',
		backgroundColor: null,
		disableDefaultUI: false,
		disableDoubleClickZoom: true,
		scrollwheel: true,
		draggable: true,
		draggableCursor: null, // HTML cursors: auto, default, text, help, crosshair, move, wait, pointer, progress, e-resize, ne-resize, nw-resize, n-resize, se-resize, sw-resize, s-resize, w-resize, or any URL
		draggingCursor: null,  // HTML cursors: auto, default, text, help, crosshair, move, wait, pointer, progress, e-resize, ne-resize, nw-resize, n-resize, se-resize, sw-resize, s-resize, w-resize, or any URL
		keyboardShortcuts: true,
	  type: "ROADMAP",        // HYBRID, ROADMAP, SATELLITE, TERRAIN
		detect_location: true,  // should the browser attempt to use geolocation detection features of HTML5?
		center_latitude: 0,
		center_longitude: 0, 
		zoom: 1,
		maxZoom: null,
		minZoom: null,
		auto_adjust : false,    // adjust the map to the markers if set to true
		auto_zoom: true,        // zoom given by auto-adjust
		mapTypeControl: true,
		panControl: true,
	  zoomControl: true,
	  scaleControl: true,
	  streetViewControl: true,
	  overviewMapControl: true,
		bounds: []              // adjust map to these limits. Should be [{"lat": , "lng": }]
	},				
	
	//markers + info styling
	markers_conf: {
		// Marker config
		clickable: true,
		cursor: null, // HTML cursors: auto, default, text, help, crosshair, move, wait, pointer, progress, e-resize, ne-resize, nw-resize, n-resize, se-resize, sw-resize, s-resize, w-resize, or any URL
		draggable: false,
		flat: false,
		optimized: true,
		raiseOnDrag: true,
		title: "",
		visible: true,
		zIndex: null,
		// MarkerImage config
	  picture : "",
		width: 22,
		length: 32,
		anchor: "bottom_center",  //anchor position of the marker image. options: top_left, top_center, top_right, center_left, center, center_right, bottom_right, bottom_center, bottom_left
		scaledWidth: 22,
		scaledLength: 32,
		origin_x: 0,
		origin_y: 0,
		//clustering config
	  do_clustering: true,			// do clustering if set to true
	  clusterer_gridSize: 50,		// the more the quicker but the less precise
		clusterer_maxZoom:  5,		// removes clusterer  at this zoom level
		randomize: false,         // Google maps can't display two markers which have the same coordinates. This randomizer enables to prevent this situation from happening.
		max_random_distance: 100, // in meters. Each marker coordinate could be altered by this distance in a random direction
		list_container: null      // id of the ul that will host links to all markers
	},
	
	//Stored variables
	markers: [],							  // contains all markers. A marker contains the following: {"description": , "longitude": , "title":, "latitude":, "picture": "", "width": "", "length": "", "sidebar": "", "google_object": google_marker}
	bounds_object: null,				// contains current bounds from markers, polylines etc...
	polygons: [], 						  // contains raw data, array of arrays (first element could be a hash containing options)
	polylines: [], 						  // contains raw data, array of arrays (first element could be a hash containing options)
	circles: [],                // contains raw data, array of hash
	rectangles: [],							// contains raw data
  markerClusterer: null,			// contains all marker clusterers
  
	//Polygon Styling
	polygons_conf: {						// default style for polygons
		strokeColor: "#FFAA00",
  	strokeOpacity: 0.8,
  	strokeWeight: 2,
    fillColor: "#000000",
  	fillOpacity: 0.35,
		clickable: true,
		geodesic: false,
		zIndex: null
	},

	//Polyline Styling		
	polylines_conf: {						//default style for polylines
		strokeColor: "#FF0000",
  	strokeOpacity: 1,
  	strokeWeight: 2
	},
		
	//Circle Styling	
	circles_conf: {							//default style for circles
	  fillColor: "#00AAFF",
	  fillOpacity: 0.35,
		strokeColor: "#FFAA00",
	  strokeOpacity: 0.8,
	  strokeWeight: 2,
		clickable: false,
		zIndex: null
	},
		
	//Rectangle Styling
	rectangle_conf: {
		 fillColor: "#00AAFF",
     fillOpacity: 0.35,
		 strokeColor: "#FFAA00",
		 strokeOpacity: 0.8,
		 strokeWeight: 2,
		 clickable: true,
		 zIndex: null
	},
	
	//Direction Settings
	direction_conf: {
		panel_id: 					null,
		display_panel: 			false,
		origin: 						null, 
    destination: 				null,
		waypoints: 					[], //[{location: "toulouse,fr", stopover: true}, {location: "Clermont-Ferrand, fr", stopover: true}]
    optimizeWaypoints: 	false,
		unitSystem: 				"METRIC", //IMPERIAL
		avoidHighways: 			false,
		avoidTolls: 				false,
		region: 						null, 
		travelMode: 				"DRIVING" //WALKING, BICYCLING
	},
	
	//initializes the map
	initialize: function() {
		// Attempt to use browser geolocation to detect users location and set the center of the map based on that. If it doesn't work 
		// or isn't enabled then fall back on the default location 
		var myLocation;
		var defaultLocation = new google.maps.LatLng(this.map_options.center_latitude, this.map_options.center_longitude);
		if (this.map_options.detect_location == true) { 
			myLocation = this.findMyLocation(defaultLocation); 
		} else {
			myLocation = defaultLocation;
		}
		
		this.map = new google.maps.Map(document.getElementById(this.map_options.id), {
			  maxZoom: this.map_options.maxZoom,
			  minZoom: this.map_options.minZoom,
				zoom: this.map_options.zoom,
		 		center: myLocation,
				mapTypeId: google.maps.MapTypeId[this.map_options.type],
				mapTypeControl: this.map_options.mapTypeControl,
				panControl: this.map_options.panControl,
				zoomControl: this.map_options.zoomControl,
				scaleControl: this.map_options.scaleControl,
				streetViewControl: this.map_options.streetViewControl,
		});
		//resets sidebar if needed
		this.reset_sidebar_content();
	},
	
	findMyLocation: function(defaultLocation) {
		var initialLocation;

		if(navigator.geolocation) {
	    navigator.geolocation.getCurrentPosition(function(position) {
	      initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
	    }, function() {
	      initialLocation = defaultLocation;
		    contentString = "Error: The Geolocation service failed.";
	    });
	  } else {
	    // Browser doesn't support Geolocation
	    initialLocation = defaultLocation;
	    contentString = "Error: Your browser doesn't support geolocation.";
	  }

		return initialLocation;
	},
<commit_msg>fixed geolocation asynchronous timing issue so map actually loadslike it's supposed to<commit_after>var Gmaps4Rails = {
	//map config
	map: null,									// contains the map we're working on
	visibleInfoWindow: null,
  
	//Map settings
	map_options: {
	  id: 'gmaps4rails_map',
		backgroundColor: null,
		disableDefaultUI: false,
		disableDoubleClickZoom: true,
		scrollwheel: true,
		draggable: true,
		draggableCursor: null, // HTML cursors: auto, default, text, help, crosshair, move, wait, pointer, progress, e-resize, ne-resize, nw-resize, n-resize, se-resize, sw-resize, s-resize, w-resize, or any URL
		draggingCursor: null,  // HTML cursors: auto, default, text, help, crosshair, move, wait, pointer, progress, e-resize, ne-resize, nw-resize, n-resize, se-resize, sw-resize, s-resize, w-resize, or any URL
		keyboardShortcuts: true,
	  type: "ROADMAP",        // HYBRID, ROADMAP, SATELLITE, TERRAIN
		detect_location: true,  // should the browser attempt to use geolocation detection features of HTML5?
		center_latitude: 0,
		center_longitude: 0, 
		zoom: 1,
		maxZoom: null,
		minZoom: null,
		auto_adjust : false,    // adjust the map to the markers if set to true
		auto_zoom: true,        // zoom given by auto-adjust
		mapTypeControl: true,
		panControl: true,
	  zoomControl: true,
	  scaleControl: true,
	  streetViewControl: true,
	  overviewMapControl: true,
		bounds: []              // adjust map to these limits. Should be [{"lat": , "lng": }]
	},				
	
	//markers + info styling
	markers_conf: {
		// Marker config
		clickable: true,
		cursor: null, // HTML cursors: auto, default, text, help, crosshair, move, wait, pointer, progress, e-resize, ne-resize, nw-resize, n-resize, se-resize, sw-resize, s-resize, w-resize, or any URL
		draggable: false,
		flat: false,
		optimized: true,
		raiseOnDrag: true,
		title: "",
		visible: true,
		zIndex: null,
		// MarkerImage config
	  picture : "",
		width: 22,
		length: 32,
		anchor: "bottom_center",  //anchor position of the marker image. options: top_left, top_center, top_right, center_left, center, center_right, bottom_right, bottom_center, bottom_left
		scaledWidth: 22,
		scaledLength: 32,
		origin_x: 0,
		origin_y: 0,
		//clustering config
	  do_clustering: true,			// do clustering if set to true
	  clusterer_gridSize: 50,		// the more the quicker but the less precise
		clusterer_maxZoom:  5,		// removes clusterer  at this zoom level
		randomize: false,         // Google maps can't display two markers which have the same coordinates. This randomizer enables to prevent this situation from happening.
		max_random_distance: 100, // in meters. Each marker coordinate could be altered by this distance in a random direction
		list_container: null      // id of the ul that will host links to all markers
	},
	
	//Stored variables
	markers: [],							  // contains all markers. A marker contains the following: {"description": , "longitude": , "title":, "latitude":, "picture": "", "width": "", "length": "", "sidebar": "", "google_object": google_marker}
	bounds_object: null,				// contains current bounds from markers, polylines etc...
	polygons: [], 						  // contains raw data, array of arrays (first element could be a hash containing options)
	polylines: [], 						  // contains raw data, array of arrays (first element could be a hash containing options)
	circles: [],                // contains raw data, array of hash
	rectangles: [],							// contains raw data
  markerClusterer: null,			// contains all marker clusterers
  
	//Polygon Styling
	polygons_conf: {						// default style for polygons
		strokeColor: "#FFAA00",
  	strokeOpacity: 0.8,
  	strokeWeight: 2,
    fillColor: "#000000",
  	fillOpacity: 0.35,
		clickable: true,
		geodesic: false,
		zIndex: null
	},

	//Polyline Styling		
	polylines_conf: {						//default style for polylines
		strokeColor: "#FF0000",
  	strokeOpacity: 1,
  	strokeWeight: 2
	},
		
	//Circle Styling	
	circles_conf: {							//default style for circles
	  fillColor: "#00AAFF",
	  fillOpacity: 0.35,
		strokeColor: "#FFAA00",
	  strokeOpacity: 0.8,
	  strokeWeight: 2,
		clickable: false,
		zIndex: null
	},
		
	//Rectangle Styling
	rectangle_conf: {
		 fillColor: "#00AAFF",
     fillOpacity: 0.35,
		 strokeColor: "#FFAA00",
		 strokeOpacity: 0.8,
		 strokeWeight: 2,
		 clickable: true,
		 zIndex: null
	},
	
	//Direction Settings
	direction_conf: {
		panel_id: 					null,
		display_panel: 			false,
		origin: 						null, 
    destination: 				null,
		waypoints: 					[], //[{location: "toulouse,fr", stopover: true}, {location: "Clermont-Ferrand, fr", stopover: true}]
    optimizeWaypoints: 	false,
		unitSystem: 				"METRIC", //IMPERIAL
		avoidHighways: 			false,
		avoidTolls: 				false,
		region: 						null, 
		travelMode: 				"DRIVING" //WALKING, BICYCLING
	},
	
	//initializes the map
	initialize: function() {
		var defaultLocation = new google.maps.LatLng(this.map_options.center_latitude, this.map_options.center_longitude);
		
		this.map = new google.maps.Map(document.getElementById(this.map_options.id), {
			  maxZoom: this.map_options.maxZoom,
			  minZoom: this.map_options.minZoom,
				zoom: this.map_options.zoom,
		 		center: myLocation,
				mapTypeId: google.maps.MapTypeId[this.map_options.type],
				mapTypeControl: this.map_options.mapTypeControl,
				panControl: this.map_options.panControl,
				zoomControl: this.map_options.zoomControl,
				scaleControl: this.map_options.scaleControl,
				streetViewControl: this.map_options.streetViewControl,
		});
		
		// Attempt to use browser geolocation to detect users location and set the center of the map based on that. If it doesn't work 
		// or isn't enabled then fall back on the default location 
		if (this.map_options.detect_location == true) { 
			this.findMyLocation(); 
		}
		
		//resets sidebar if needed
		this.reset_sidebar_content();
	},
	
	findMyLocation: function() {
		if(navigator.geolocation) {
	    navigator.geolocation.getCurrentPosition(function(position) {
	      var myLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
				Gmaps4Rails.map.setCenter(myLocation)
	    }, function(error) {
		    contentString = "Error: The Geolocation service failed.";
	    });
	  } else {
	    // Browser doesn't support Geolocation
	    contentString = "Error: Your browser doesn't support geolocation.";
	  }
	},

{'fraction_non_alphanumeric': 0.10939811570505334, 'fraction_numerical': 0.009732928443510083, 'mean_word_length': 3.3881106935428766, 'pattern_counts': {'":': 22, '<': 3, '<?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': '5916544', 'n_tokens_mistral': 4745, 'n_tokens_neox': 4094, 'n_words': 1217}