/
app.config.js
144 lines (118 loc) · 5.01 KB
/
app.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'use strict';
(function () {
angular
.module('examples')
.config(urlRouterConfiguration)
.config(titleConfiguration)
.config(authConfiguration)
.config(gnapMapConfiguration)
.run(handleStateChangeError)
.run(gnapMapRun);
var defaultPage = '/map';
titleConfiguration.$inject = ['titleServiceProvider'];
function titleConfiguration(titleServiceProvider) {
titleServiceProvider.setDefaultTitle({ text: '' });
titleServiceProvider.setSeparator('-');
titleServiceProvider.setPrefix({ text: 'GNaP Map Examples »' });
titleServiceProvider.setSuffix({ text: '' });
}
urlRouterConfiguration.$inject = ['$urlRouterProvider'];
function urlRouterConfiguration($urlRouterProvider) {
// when there is an empty route, redirect to the default page
$urlRouterProvider.when('', defaultPage)
.when('/', defaultPage);
// when no matching route found redirect to error 404
$urlRouterProvider.otherwise('/notfound');
}
authConfiguration.$inject = ['$httpProvider'];
function authConfiguration($httpProvider) {
$httpProvider.interceptors.push('authenticationInterceptor');
}
gnapMapConfiguration.$inject = ['mapManagerProvider', 'layerConfigProvider', 'mapGeoDataProvider', 'mapTechGoogleProvider'];
function gnapMapConfiguration(mapManagerProvider, layerConfigProvider, mapGeoDataProvider, mapTechGoogleProvider) {
mapManagerProvider.setMapState('main.map');
mapManagerProvider.setMapInfoState('main.map.info');
mapManagerProvider.setTranslationLocationBase('main.map.');
layerConfigProvider.setDataLayers({
point: {
itemType: 'point',
resourceUri: 'points',
minZoomLevel: 0,
translationId: 'main.map.points',
iconUrl: 'https://dl.dropboxusercontent.com/u/10093725/mapicons/brown/restaurant/bar.png',
zIndex: 1,
cache: true,
displayLayer: true
},
point2: {
itemType: 'point2',
resourceUri: 'points2',
minZoomLevel: 1,
translationId: 'main.map.points2',
zIndex: 2,
displayLayer: true,
hasNoDetails: true,
cache: false
},
random: {
itemType: 'random',
resourceUri: 'random',
minZoomLevel: 2,
translationId: 'main.map.random',
iconUrl: 'https://dl.dropboxusercontent.com/u/10093725/mapicons/brown/transport/airport.png',
zIndex: 3,
displayLayer: true,
hasNoDetails: true,
moving: true
}
});
mapGeoDataProvider.setEndpointUri('http://localhost:9003/');
// Configure the desired defaults of every map technology you're using
mapTechGoogleProvider.setDefaults({
zoomLevel: 8,
center: { lat: 50.762437, lng: 4.245922 }
//defaultStyleFunction: ...
});
}
handleStateChangeError.$inject = ['$rootScope', '$state', '$location', 'sessionService', 'unhandledErrorChannel'];
function handleStateChangeError($rootScope, $state, $location, sessionService, unhandledErrorChannel) {
$rootScope.$on('$stateChangeError',
function (event, toState, toParams, fromState, fromParams, error) {
// unauthorized
if (error.status === 401) {
event.preventDefault();
// end the current session
sessionService.abandonSession();
// go to login screen (only once!)
if (toState.name !== 'public.login') {
$location.url('/login').search({ 'redirect_state': toState.name });
}
}
// forbidden
else if (error.status === 403) {
event.preventDefault();
// redirect to 'forbidden' error page
$state.go('main.forbidden');
}
// any other case
else {
unhandledErrorChannel.errorOccurred(error);
}
});
}
gnapMapRun.$inject = ['layerConfig', 'mapGeoData', 'settings'];
function gnapMapRun(layerConfig, mapGeoData, settings) {
mapGeoData.setConstructResourceUriFunction(function(dataLayer, all) {
return all ? dataLayer.resourceUri : dataLayer.resourceUri + '/bounds';
});
layerConfig.setDataLayers({
point2: {
getStyleFunction: function(feature, iconUrl, layerProperties, zoomLevel) {
return {
icon: settings.iconUrl
};
}
}
});
}
})();