FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
angular-google-maps/example/overlay-map-type.html at master · angular-ui/angular-google-maps · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Nov 30, 2018. It is now read-only.
angular-ui
/
angular-google-maps
Public archive
Notifications
You must be signed in to change notification settings
Fork
1.1k
Star
2.5k
Code
Issues
337
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
angular-google-maps
/
example
/
overlay-map-type.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
378 lines (352 loc) · 14.1 KB
Breadcrumbs
angular-google-maps
/
example
/
overlay-map-type.html
Copy path
File metadata and controls
378 lines (352 loc) · 14.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<!DOCTYPE html
>
<
html
xmlns:ng
="
http://angularjs.org
"
id
='
ng-app
'
ng-app
="
angular-google-maps-example
"
>
<
head
>
<
meta
charset
="
UTF-8
"
>
<
title
>
map-type examples for angular-google-maps
</
title
>
<
link
href
="
//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css
"
rel
="
stylesheet
"
type
="
text/css
"
>
<
link
href
="
//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css
"
rel
="
stylesheet
"
type
="
text/css
"
>
<
link
href
='
http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,800,600,300,700
'
rel
='
stylesheet
'
type
='
text/css
'
>
<
link
href
="
//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.css
"
type
="
text/css
"
>
<
link
href
="
assets/stylesheets/example.css
"
rel
="
stylesheet
"
type
="
text/css
"
>
<
style
>
body
{
padding-top
:
70
px
;
padding-bottom
:
30
px
;
}
.
angular-google-map-container
{
height
:
350
px
;
}
</
style
>
</
head
>
<
body
ng-controller
="
maptypeExampleController
"
>
<
div
class
="
navbar navbar-inverse navbar-fixed-top
"
>
<
div
class
="
container
"
>
<
div
class
="
navbar-header
"
>
<
a
href
="
#
"
class
="
navbar-brand
"
>
map-type directive
</
a
>
</
div
>
<
div
class
="
navbar-collapse collapse
"
>
<
ul
class
="
nav navbar-nav
"
>
<
li
>
<
a
href
="
#usage
"
>
Usage
</
a
>
</
li
>
<
li
class
="
dropdown
"
>
<
a
href
="
#examples
"
data-toggle
="
dropdown
"
>
Examples
<
span
class
="
caret
"
>
</
span
>
</
a
>
<
ul
class
="
dropdown-menu
"
role
="
menu
"
>
<
li
>
<
a
href
="
#basic-overlay
"
>
Custom map type overlayed
</
a
>
</
li
>
<
li
>
<
a
href
="
#image-overlay
"
>
Image map type overlayed
</
a
>
</
li
>
<
li
>
<
a
href
="
#image-single
"
>
Image map type single layer
</
a
>
</
li
>
<
li
>
<
a
href
="
#combo
"
>
Combo
</
a
>
</
li
>
</
ul
>
</
li
>
</
ul
>
</
div
>
</
div
>
</
div
>
<
div
class
="
container
"
>
<
div
class
="
jumbotron
"
>
<
h2
ng-cloak
>
<
code
>
map-type
</
code
>
directive for
<
strong
>
angular-google-maps {{version}}
</
strong
>
</
h2
>
<
p
>
As seen on
<
a
href
="
https://developers.google.com/maps/documentation/javascript/maptypes
"
>
Google Maps Javascript API v3 Map Types documentation
</
a
>
.
</
p
>
</
div
>
<
h2
>
Directive usage
</
h2
>
<
div
class
="
panel panel-default
"
>
<
div
class
="
panel-heading
"
>
<
h3
class
="
panel-title
"
>
map-type
</
h3
>
</
div
>
<
div
class
="
panel-body
"
>
<
h4
>
Usage
</
h4
>
<
p
>
The
<
code
>
map-type
</
code
>
directive is used to add custom map types, as overlays or single layers.
</
p
>
<
pre
class
="
prettyprint
"
>
<ui-gmap-map-type
options='{expression}'
id="'{string}'"
show='{expression}'
refresh='{expression}'
>
</ui-gmap-map-type
>
</
pre
>
<
h4
>
Parameters
</
h4
>
<
p
>
Required properties are in red.
</
p
>
<
table
class
="
table table-bordered table-striped
"
>
<
thead
>
<
tr
>
<
th
>
Param
</
th
>
<
th
>
Type
</
th
>
<
th
>
Details
</
th
>
</
tr
>
</
thead
>
<
tbody
>
<
tr
>
<
td
>
options
</
td
>
<
td
>
<
span
class
="
label label-danger
"
>
expression
</
span
>
</
td
>
<
td
>
Map type options, including in particular
<
code
>
getTile
</
code
>
or
<
code
>
getTileUrl
</
code
>
methods.
For complete list of options see
<
a
href
="
https://developers.google.com/maps/documentation/javascript/maptypes#MapTypeInterface
"
target
="
_blank
"
>
Google Maps API documentation
</
a
>
.
</
td
>
</
tr
>
<
tr
>
<
td
>
id
</
td
>
<
td
>
<
span
class
="
label label-info
"
>
string
</
span
>
</
td
>
<
td
>
Map type id, to be used in the controler to display the maptype as a single layer.
</
td
>
</
tr
>
<
tr
>
<
td
>
show
</
td
>
<
td
>
<
span
class
="
label label-info
"
>
expression
</
span
>
</
td
>
<
td
>
Scope variable used to show the maptype as an overlay. Defaults to
<
code
>
true
</
code
>
, unless
<
code
>
id
</
code
>
has been defined
</
td
>
</
tr
>
<
tr
>
<
td
>
refresh
</
td
>
<
td
>
<
span
class
="
label label-info
"
>
expression
</
span
>
</
td
>
<
td
>
Variable or expression to watch, which will trigger a maptype refresh when changing.
<
br
>
Useful in the case where the
<
code
>
getTileUrl
</
code
>
is dynamically defined (for example using
filters, options…), and you want to apply changes immediately.
</
td
>
</
tr
>
</
tbody
>
</
table
>
</
div
>
</
div
>
<
h2
>
Examples
</
h2
>
<
div
class
="
page-header
"
>
<
h3
id
="
basic-overlay
"
>
Map with Custom map type overlayed
</
h3
>
</
div
>
<
div
class
="
row
"
>
<
div
class
="
col-md-6
"
>
<
p
>
The most simple way to overlay a custom map type is just to define the map type options in the controller
and then add the directive in the google-map widget.
</
p
>
<
p
>
In this example a map type displaying black squares is overlayed on the map. This can be hidden changing the
<
code
>
showOverlay
</
code
>
value in the scope, as seen in
<
a
href
="
https://developers.google.com/maps/documentation/javascript/examples/maptype-overlay
"
target
="
_blank
"
>
Overlay map types
</
a
>
API example.
</
p
>
<
ui-gmap-google-map
center
="
map1.center
"
zoom
="
map1.zoom
"
>
<
ui-gmap-map-type
options
="
squaresMapType
"
show
="
map1.showOverlay
"
>
</
ui-gmap-map-type
>
</
ui-gmap-google-map
>
<
a
class
="
btn btn-primary
"
ng-click
="
map1.showOverlay = !map1.showOverlay
"
>
Toggle overlay
</
a
>
</
div
>
<
div
class
="
col-md-6
"
>
<
h4
>
Javascript
</
h4
>
<
pre
class
="
prettyprint
"
>
// Define map type options
$scope.squaresMapType = {
getTile: function(coord, zoom, ownerDocument) {
var div = ownerDocument.createElement('div');
div.innerHTML = coord;
div.style.width = this.tileSize.width + 'px';
div.style.height = this.tileSize.height + 'px';
div.style.fontSize = '10';
div.style.borderStyle = 'solid';
div.style.borderWidth = '1px';
div.style.borderColor = '#AAAAAA';
return div;
},
tileSize: new google.maps.Size(256, 256),
name: 'Black Squares',
maxZoom: 19,
};
// Define map options
$scope.map1 = {
center: {
latitude: 41.850033,
longitude: -87.6500523
},
showOverlay: true,
zoom: 10,
};
</
pre
>
<
h4
>
HTML
</
h4
>
<
pre
class
="
prettyprint
"
>
<ui-gmap-google-map center="map1.center" zoom="map1.zoom"
>
<ui-gmap-map-type options="squaresMapType" show="map1.showOverlay"
>
</ui-gmap-map-type
>
</ui-gmap-google-map
>
<a ng-click="map1.showOverlay = !map1.showOverlay"
>
Toggle overlay</a
>
</
pre
>
</
div
>
</
div
>
<
div
class
="
page-header
"
>
<
h3
id
="
image-overlay
"
>
Map with Image map type overlayed
</
h3
>
</
div
>
<
div
class
="
row
"
>
<
div
class
="
col-md-6
"
>
<
p
>
You can overlay an Image map type pretty much the same way, just by defining the method
<
code
>
getTileUrl
</
code
>
in its options. MapTypes are handled internally and you don't need to care about
creating a custom type or using Google API ones.
</
p
>
<
p
>
This example overlays Moscone Center pictures over the map, as seen in
<
a
href
="
https://developers.google.com/maps/documentation/javascript/examples/maptype-image-overlay
"
target
="
_blank
"
>
Overlaying an image map type
</
a
>
API example.
</
p
>
<
ui-gmap-google-map
center
="
map2.center
"
zoom
="
map2.zoom
"
options
="
map2.options
"
>
<
ui-gmap-map-type
options
="
mosconeCenterMapType
"
>
</
ui-gmap-map-type
>
</
ui-gmap-google-map
>
</
div
>
<
div
class
="
col-md-6
"
>
<
h4
>
Javascript
</
h4
>
<
pre
class
="
prettyprint
"
>
// Define map type options
$scope.mosconeCenterMapType = {
getTileUrl: function(coord, zoom) {
var bounds = {
17: [[20969, 20970], [50657, 50658]],
18: [[41939, 41940], [101315, 101317]],
19: [[83878, 83881], [202631, 202634]],
20: [[167757, 167763], [405263, 405269]]
};
if (zoom
<
17
||
zoom
>
20 ||
bounds[zoom][0][0]
>
coord.x || coord.x
>
bounds[zoom][0][1] ||
bounds[zoom][1][0]
>
coord.y || coord.y
>
bounds[zoom][1][1]) {
return null;
}
return [
'http://www.gstatic.com/io2010maps/tiles/5/L2_', zoom, '_',
coord.x, '_', coord.y, '.png'
].join('');
},
tileSize: new google.maps.Size(256, 256)
};
// Define map options
$scope.map2 = {
center: {
latitude: 37.78313383212,
longitude: -122.4039494991302
},
zoom: 18,
options: {
minZoom: 17,
maxZoom: 20
}
};
</
pre
>
<
h4
>
HTML
</
h4
>
<
pre
class
="
prettyprint
"
>
<ui-gmap-google-map center="map2.center" zoom="map2.zoom" options="map2.options"
>
<ui-gmap-map-type options="mosconeCenterMapType"
>
</ui-gmap-map-type
>
</ui-gmap-google-map
>
</
pre
>
</
div
>
</
div
>
<
div
class
="
page-header
"
>
<
h3
id
="
image-single
"
>
Map with Image map type as single layer
</
h3
>
</
div
>
<
div
class
="
row
"
>
<
div
class
="
col-md-6
"
>
<
p
>
You can alternatively give the directive an
<
code
>
id
</
code
>
attribute, so the map type can be used as a
single layer like the ROAD, SATELLITE or other
<
a
href
="
https://developers.google.com/maps/documentation/javascript/maptypes#BasicMapTypes
"
target
="
_blank
"
>
basic map types
</
a
>
.
</
p
>
<
ul
>
<
li
>
<
code
>
show
</
code
>
attribute is not used for single-layer map types, you need to use controls or
explicitely set the map type you want in the javascript code.
</
li
>
<
li
>
Additionnaly, you need to specify
<
code
>
maxZoom
</
code
>
parameter in the maptype options when using the
maptype as a single layer.
</
li
>
</
ul
>
<
p
>
This example displays a map of the moon instead of the earth, as seen on
<
a
href
="
https://developers.google.com/maps/documentation/javascript/examples/maptype-image
"
target
="
_blank
"
>
Image map types
</
a
>
API example.
</
p
>
<
ui-gmap-google-map
center
="
map3.center
"
zoom
="
map3.zoom
"
options
="
map3.options
"
>
<
ui-gmap-map-type
id
="
moon
"
options
="
moonMapType
"
>
</
map-type
>
</
ui-gmap-google-map
>
</
div
>
<
div
class
="
col-md-6
"
>
<
h4
>
Javascript
</
h4
>
<
pre
class
="
prettyprint
"
>
// Define map type options.
$scope.moonMapType = {
getTileUrl: function(coord, zoom) {
var normalizedCoord = getNormalizedCoord(coord, zoom);
if (!normalizedCoord) {
return null;
}
var bound = Math.pow(2, zoom);
return 'http://mw1.google.com/mw-planetary/lunar/lunarmaps_v1/clem_bw' +
'/' + zoom + '/' + normalizedCoord.x + '/' +
(bound - normalizedCoord.y - 1) + '.jpg';
},
tileSize: new google.maps.Size(256, 256),
maxZoom: 9, // This attribute is mandatory
minZoom: 0,
radius: 1738000,
name: 'Moon'
};
// Define map options
$scope.map3 = {
center: {
latitude: 0,
longitude: 0
},
zoom: 1,
options: {
mapTypeId: 'moon',
mapTypeControlOptions: {
mapTypeIds: ['moon']
}
}
};
</
pre
>
<
h4
>
HTML
</
h4
>
<
pre
class
="
prettyprint
"
>
<ui-gmap-google-map center="map3.center" zoom="map3.zoom" options="map3.options"
>
<ui-gmap-map-type id="moon" options="moonMapType"
>
</ui-gmap-map-type
>
</ui-gmap-google-map
>
</
pre
>
</
div
>
</
div
>
<
div
class
="
page-header
"
>
<
h3
id
="
combo
"
>
Combo : map type overlayed and map type as single layer
</
h3
>
</
div
>
<
div
class
="
row
"
>
<
div
class
="
col-md-6
"
>
<
p
>
With several
<
code
>
map-type
</
code
>
directives you can mix custom overlays and single layers, using
<
code
>
id
</
code
>
and
<
code
>
show
</
code
>
parameters. This is even possible to render the maptype in both ways,
despite you may not want do this.
</
p
>
<
p
>
This example features the previously defined "
<
em
>
moon
</
em
>
" image map type, and "
<
em
>
squares
</
em
>
" map type.
One is visible using the controls, the other is overlayed on the map (and can be toggled on/off using
<
code
>
show
</
code
>
).
</
p
>
<
ui-gmap-google-map
center
="
map4.center
"
zoom
="
map4.zoom
"
options
="
map4.options
"
>
<
ui-gmap-map-type
options
="
squaresMapType
"
>
</
ui-gmap-map-type
>
<
ui-gmap-map-type
id
="
moon
"
options
="
moonMapType
"
>
</
ui-gmap-map-type
>
</
ui-gmap-google-map
>
</
div
>
<
div
class
="
col-md-6
"
>
<
h4
>
Javascript
</
h4
>
<
pre
class
="
prettyprint
"
>
// Previously defined map types are reused
// Define map options
$scope.map4 = {
center: {
latitude: 0,
longitude: 0
},
zoom: 3,
options: {
mapTypeControlOptions: {
mapTypeIds: ['moon', google.maps.MapTypeId.ROADMAP]
}
}
};
</
pre
>
<
h4
>
HTML
</
h4
>
<
pre
class
="
prettyprint
"
>
<ui-gmap-google-map center="map4.center" zoom="map4.zoom" options="map4.options"
>
<ui-gmap-map-type id="moon" options="moonMapType"
>
</ui-gmap-map-type
>
<ui-gmap-map-type options="squaresMapType"
>
</ui-gmap-map-type
>
</ui-gmap-google-map
>
</
pre
>
</
div
>
</
div
>
</
div
>
<
script
src
="
../website_libs/dev_deps.js
"
>
</
script
>
<
script
src
="
http://maps.googleapis.com/maps/api/js?language=en&v=3.17
"
>
</
script
>
<
script
src
="
http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js
"
>
</
script
>
<
script
src
="
//cdnjs.cloudflare.com/ajax/libs/prettify/r298/run_prettify.js
"
type
="
text/javascript
"
>
</
script
>
<
script
src
="
//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.8.0/lodash.min.js
"
type
="
text/javascript
"
>
</
script
>
<
script
src
="
http://cdn.rawgit.com/nmccready/angular-simple-logger/0.0.1/dist/index.js
"
>
</
script
>
<
script
src
="
../dist/angular-google-maps.js
"
>
</
script
>
<
script
src
="
assets/scripts/controllers/overlay-map-type.js
"
>
</
script
>
<
script
src
="
assets/scripts/controllers/templates/info.js
"
>
</
script
>
<
script
src
="
http://localhost:35729/livereload.js
"
>
</
script
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL