/
courtSearchInfo.ctrl.js
60 lines (48 loc) · 1.63 KB
/
courtSearchInfo.ctrl.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
'use strict';
angular.module('yourStlCourts').controller('CourtSearchInfoCtrl', function ($state, $window, court, leafletData, LegalRights){
var ctrl = this;
ctrl.courtInfo = court;
ctrl.courtOnMap = {
lat:51.505,
lng:-0.09,
zoom: 14
};
leafletData.getMap("mapid").then(function(map){
map.dragging.disable();
});
ctrl.courtMarkers = {};
var courtDefaultIcon = {
iconUrl: 'images/marker-icon.png',
shadowUrl: 'images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
};
function getCourtDirectionLink(courtInfo) {
var address = courtInfo.address.replace(' ', '+');
var city = courtInfo.city;
var state = courtInfo.state;
var zip = courtInfo.zip;
var addressParts = [address, city, state, zip];
return 'https://maps.google.com?saddr=Current+Location&daddr=' + addressParts.join('+');
}
if(!ctrl.courtInfo) {
$state.go('home');
} else {
ctrl.courtDirectionLink = getCourtDirectionLink(ctrl.courtInfo);
ctrl.courtOnMap.lat = ctrl.courtInfo.latitude;
ctrl.courtOnMap.lng = ctrl.courtInfo.longitude;
ctrl.courtMarkers.m1 = {lat: ctrl.courtInfo.latitude, lng: ctrl.courtInfo.longitude, message: ctrl.courtInfo.address, icon: courtDefaultIcon};
ctrl.courtName = ctrl.courtInfo.name;
ctrl.courtPhone = ctrl.courtInfo.phone;
ctrl.phoneExtension = ctrl.courtInfo.extension;
ctrl.courtWebsite = ctrl.courtInfo.website;
}
ctrl.printCourtInfo = function () {
$window.print();
};
ctrl.openLegalRightsLink = function(){
LegalRights.openLegalRightsLink(ctrl.courtInfo);
}
});