Project

General

Profile

1
var module = angular.module('reposMapUI', []);
2

    
3
function reposMapCtrl($scope, $http, $sce, $location) {
4
	
5
	common_init($scope, $http, $sce, $location);
6
	
7
	$scope.mapHeight = "400px";
8
	
9
	$scope.updateReposMap = function() {
10
		$scope.showSpinner();
11
		$http.get('listRepositories.map')
12
        .success(
13
            function(data) {
14
            	$scope.redrawReposMap(data);
15
            	$scope.hideSpinner();
16
            }
17
        ).error(
18
            function() {
19
            	$scope.showError('Something really bad must have happened to our fellow hamster..');
20
            	$scope.hideSpinner();
21
            }
22
        );
23
	}	
24

    
25
	$scope.redrawReposMap = function(entries) {
26
		
27
		$scope.resizeMainElement(document.getElementById('map_canvas_container'));
28
		
29
		var map = new google.maps.Map(document.getElementById("map_canvas"), {
30
			zoom: 4,
31
			center: new google.maps.LatLng(44, 6),
32
			disableDefaultUI: true,
33
		    zoomControl: true,
34
			mapTypeId: google.maps.MapTypeId.ROADMAP
35
		});
36
		
37
		angular.forEach(entries, function(repo) {
38
	
39
			var marker = new google.maps.Marker({
40
				map: map,
41
				position: new google.maps.LatLng(repo.lat, repo.lng),
42
				animation: google.maps.Animation.DROP,
43
				title: repo.name
44
			});
45
			
46
			google.maps.event.addListener(marker, 'click', function() {
47
				$scope.showDetails(repo.id, repo.name);
48
			});
49
		});
50
	}
51
	
52
	$scope.updateReposMap();
53
}
54

    
55
window.onresize = function() {
56
	var elem = document.getElementById('map_canvas_container');
57
    angular.element(elem).scope().resizeMainElement(elem);
58
};
59

    
(7-7/7)