googleCtrl.js
7.08 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
"use strict";
angular.module('newApp')
.controller('googleCtrl', ['$scope', function ($scope) {
$scope.$on('$viewContentLoaded', function () {
var simple_map;
var styled_map;
var route_map;
var cluster_map;
var geocoding_map;
if ($("#simple-map").length) {
simple_map = new GMaps({
el: '#simple-map',
lat: -12.043333,
lng: -77.028333,
zoomControl: true,
zoomControlOpt: {
style: 'SMALL',
position: 'TOP_LEFT'
},
panControl: false,
streetViewControl: false,
mapTypeControl: false,
overviewMapControl: false
});
simple_map.addMarker({
lat: -12.042,
lng: -77.028333,
title: 'Marker with InfoWindow',
infoWindow: {
content: '<p>Here we are!</p>'
}
});
}
if ($("#style-map").length) {
styled_map = new GMaps({
el: '#style-map',
lat: -12.043333,
lng: -77.028333,
zoomControl: true,
zoomControlOpt: {
style: 'SMALL',
position: 'TOP_LEFT'
},
panControl: false,
streetViewControl: false,
mapTypeControl: false,
overviewMapControl: false,
// HERE BEGIN YOUR THEME THAT YOU HAVE TO INTEGRATA
styles: [{
"featureType": "water",
"elementType": "geometry",
"stylers": [{
"color": "#193341"
}]
}, {
"featureType": "landscape",
"elementType": "geometry",
"stylers": [{
"color": "#2c5a71"
}]
}, {
"featureType": "road",
"elementType": "geometry",
"stylers": [{
"color": "#29768a"
}, {
"lightness": -37
}]
}, {
"featureType": "poi",
"elementType": "geometry",
"stylers": [{
"color": "#406d80"
}]
}, {
"featureType": "transit",
"elementType": "geometry",
"stylers": [{
"color": "#406d80"
}]
}, {
"elementType": "labels.text.stroke",
"stylers": [{
"visibility": "on"
}, {
"color": "#3e606f"
}, {
"weight": 2
}, {
"gamma": 0.84
}]
}, {
"elementType": "labels.text.fill",
"stylers": [{
"color": "#ffffff"
}]
}, {
"featureType": "administrative",
"elementType": "geometry",
"stylers": [{
"weight": 0.6
}, {
"color": "#1a3541"
}]
}, {
"elementType": "labels.icon",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "poi.park",
"elementType": "geometry",
"stylers": [{
"color": "#2c5a71"
}]
}
]
// END OF STYLE
});
}
if ($("#route-map").length) {
var map = new GMaps({
el: '#route-map',
zoom: 13,
lat: -12.043333,
lng: -77.028333
});
map.travelRoute({
origin: [-12.044012922866312, -77.02470665341184],
destination: [-12.090814532191756, -77.02271108990476],
travelMode: 'driving',
step: function (e) {
$('#instructions').append('<li>' + e.instructions + '</li>');
$('#instructions li:eq(' + e.step_number + ')').delay(450 * e.step_number).fadeIn(200, function () {
map.drawPolyline({
path: e.path,
strokeColor: '#131540',
strokeOpacity: 0.6,
strokeWeight: 6
});
});
}
});
}
if ($("#cluster-map").length) {
cluster_map = new GMaps({
div: '#cluster-map',
lat: -12.043333,
lng: -77.028333,
markerClusterer: function (map) {
return new MarkerClusterer(map);
}
});
var lat_span = -12.035988012939503 - -12.050677786181573;
var lng_span = -77.01528673535154 - -77.04137926464841;
for (var i = 0; i < 100; i++) {
var latitude = Math.random() * (lat_span) + -12.050677786181573;
var longitude = Math.random() * (lng_span) + -77.04137926464841;
cluster_map.addMarker({
lat: latitude,
lng: longitude,
title: 'Marker #' + i
});
};
geocoding_map = new GMaps({
el: '#geocoding-map',
lat: -12.043333,
lng: -77.028333
});
}
if ($("#geocoding_form").length) {
$('#geocoding_form').submit(function (e) {
e.preventDefault();
GMaps.geocode({
address: $('#address').val().trim(),
callback: function (results, status) {
if (status == 'OK') {
var latlng = results[0].geometry.location;
geocoding_map.setCenter(latlng.lat(), latlng.lng());
geocoding_map.addMarker({
lat: latlng.lat(),
lng: latlng.lng()
});
}
}
});
});
}
});
}]);