<commit_before>/*
 * This file contains the Google Maps API implementation, including:
 *    - Defaults and constants.
 *    - The initialize() function.
 *    - Necessary callbacks.
 * 
 *
 *
 * Copyright 2015 <NAME>, <NAME>, <NAME>
 *
 */

function initialize() {
	var mapOptions = {
		center: new google.maps.LatLng(
					40.724531899999995,
					-73.7971586),
		zoom: 16,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}

	map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

	currentLocation = loadLocation(setMarker(marker), function(error){	
		switch(error.code) {
		case error.PERMISSION_DENIED:
			console.log("User denied permission.");
			break;
		case error.POSITION_UNAVAILABLE:
			console.log("Geolocation/GPS unavailable.");
			break;
		case error.TIMEOUT:
			console.log("Geolocation request timed out.");
			break;
		case error.UNKNOWN_ERROR:
			console.log("Something wack happened.");
			break;
		}
	});

}



// Helper Functions


function setMarker(marker){
	/*
	   var contentString = "<div class=\"align-center\"> <button class=\"align-center\" type=\"button\">Drop a Crumb</button> </div>"
	   var infowindow = new google.maps.InfoWindow({
	   content: contentString
	   });
	 */

	return function(latlng){
		var pos = new google.maps.LatLng(latlng.latitude, latlng.longitude);
		marker = new google.maps.Marker({
			map: map,
			   position: pos,
			   animation: defaultMarker.animation,
			   draggable: defaultMarker.draggable
		});
		map.panTo(marker.getPosition());

		google.maps.event.addListener(marker, 'clicked', function(){
			console.log("hello there");
			toggleBounce(marker);
			//infowindow.open(map, marker);
		})
		google.maps.event.addListener(marker, 'dragend', function(){
			map.panTo(marker.getPosition());
		});
	}
};



/* Callbacks */

function loadLocation (callback, error) {
	if (navigator.geolocation) {
		console.log("loading location now...");
		navigator.geolocation.getCurrentPosition( function(pos){
		    currentLocation['longitude'] = pos.coords.longitude;	
			currentLocation['latitude'] = pos.coords.latitude;
			callback(pos.coords);
		}, error);
	}
}
<commit_msg>Able to retrieve location and update the global currentLocation.<commit_after>/*
 * This file contains the Google Maps API implementation, including:
 *    - Defaults and constants.
 *    - The initialize() function.
 *    - Necessary callbacks.
 * 
 *
 *
 * Copyright 2015 <NAME>, <NAME>, <NAME>
 *
 */

function initialize() {
	var mapOptions = {
		center: new google.maps.LatLng(
					40.724531899999995,
					-73.7971586),
		zoom: 16,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}

	map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

	currentLocation = loadLocation(setMarker(marker), function(error){	
		switch(error.code) {
		case error.PERMISSION_DENIED:
			console.log("User denied permission.");
			break;
		case error.POSITION_UNAVAILABLE:
			console.log("Geolocation/GPS unavailable.");
			break;
		case error.TIMEOUT:
			console.log("Geolocation request timed out.");
			break;
		case error.UNKNOWN_ERROR:
			console.log("Something wack happened.");
			break;
		}
	});

}



// Helper Functions


function setMarker(marker){
	/*
	   var contentString = "<div class=\"align-center\"> <button class=\"align-center\" type=\"button\">Drop a Crumb</button> </div>"
	   var infowindow = new google.maps.InfoWindow({
	   content: contentString
	   });
	 */

	return function(latlng){
		var pos = new google.maps.LatLng(latlng.latitude, latlng.longitude);
		marker = new google.maps.Marker({
			map: map,
			   position: pos,
			   animation: defaultMarker.animation,
			   draggable: defaultMarker.draggable
		});
		map.panTo(marker.getPosition());

		google.maps.event.addListener(marker, 'clicked', function(){
			console.log("hello there");
			toggleBounce(marker);
			//infowindow.open(map, marker);
		})
		google.maps.event.addListener(marker, 'dragend', function(){
			map.panTo(marker.getPosition());
		});
	}
};



/* Callbacks */

function loadLocation (callback, error) {
	if (navigator.geolocation) {
		console.log("loading location now...");
		navigator.geolocation.getCurrentPosition( function(pos){
			currentLocation = {};
		    currentLocation['longitude'] = pos.coords.longitude;	
			currentLocation['latitude'] = pos.coords.latitude;

			console.log("\n\nLocation loaded: ");
			console.log(currentLocation);

			callback(currentLocation);
		}, error);
	}
}

{'fraction_non_alphanumeric': 0.14593140551445863, 'fraction_numerical': 0.01434655906747366, 'mean_word_length': 3.7721925133689838, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5794929', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1420, 'n_words': 286}