-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmaps.map_types.js
68 lines (52 loc) · 1.63 KB
/
gmaps.map_types.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
'use strict';
var _extend = require('lodash-compat/object/extend'),
mapTypesModule = {};
mapTypesModule.addMapType = function(mapTypeId, options) {
var mapType;
if (typeof options.getTileUrl === 'function') {
options.tileSize = options.tileSize || new google.maps.Size(256, 256);
mapType = new google.maps.ImageMapType(options);
this.map.mapTypes.set(mapTypeId, mapType);
if (GMaps.trigger) {
GMaps.trigger('map_type_added', this, mapType);
}
}
else {
throw 'getTileUrl function required.';
}
};
mapTypesModule.addOverlayMapType = function(options) {
var overlayMapTypeIndex = options.index;
delete options.index;
if (typeof options.getTile === 'function') {
if (overlayMapTypeIndex) {
this.map.overlayMapTypes.insertAt(overlayMapTypeIndex, options);
}
else {
this.map.overlayMapTypes.push(options);
}
if (GMaps.trigger) {
GMaps.trigger('overlay_map_type_added', this, options);
}
}
else {
throw 'getTile function required.';
}
};
mapTypesModule.removeOverlayMapType = function(overlayMapTypeIndex) {
var overlayMapType = this.map.overlayMapTypes.removeAt(overlayMapTypeIndex);
if (GMaps.trigger) {
GMaps.trigger('overlay_map_type_removed', this, overlayMapType);
}
};
mapTypesModule.removeOverlayMapTypes = function() {
this.map.overlayMapTypes.clear();
};
if (window.GMaps) {
GMaps.customEvents = GMaps.customEvents || [];
GMaps.customEvents = GMaps.customEvents.concat([
'map_type_added', 'overlay_map_type_added', 'overlay_map_type_removed'
]);
_extend(GMaps.prototype, mapTypesModule);
}
module.exports = mapTypesModule;