1
|
|
|
/*jslint |
2
|
|
|
regexp: true |
3
|
|
|
indent: 4 |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
/*global |
7
|
|
|
$, google, document, setTimeout |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
var Attribution = {}; |
11
|
|
|
Attribution.m_map = null; |
12
|
|
|
Attribution.m_div = null; |
13
|
|
|
|
14
|
|
|
Attribution.init = function (themap) { |
15
|
|
|
'use strict'; |
16
|
|
|
|
17
|
|
|
var self = this; |
18
|
|
|
|
19
|
|
|
this.m_map = themap; |
20
|
|
|
|
21
|
|
|
// Create div for showing copyrights. |
22
|
|
|
this.m_div = document.createElement("div"); |
23
|
|
|
this.m_div.id = "map-copyright"; |
24
|
|
|
this.m_div.style.fontSize = "11px"; |
25
|
|
|
this.m_div.style.fontFamily = "Arial, sans-serif"; |
26
|
|
|
this.m_div.style.margin = "0 2px 2px 0"; |
27
|
|
|
this.m_div.style.whiteSpace = "nowrap"; |
28
|
|
|
this.m_div.style.background = "#FFFFFF"; |
29
|
|
|
this.m_map.controls[google.maps.ControlPosition.BOTTOM_RIGHT].push(this.m_div); |
30
|
|
|
|
31
|
|
|
google.maps.event.addListener(this.m_map, "maptypeid_changed", function () { |
32
|
|
|
self.update(); |
33
|
|
|
}); |
34
|
|
|
}; |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
Attribution.update = function () { |
38
|
|
|
'use strict'; |
39
|
|
|
|
40
|
|
|
var m = this.m_map.getMapTypeId(), |
41
|
|
|
g = true, |
42
|
|
|
c = ""; |
43
|
|
|
|
44
|
|
|
if (m === "OSM" || m === "OSM/DE") { |
45
|
|
|
g = false; |
46
|
|
|
c = "Map data (C) by <a href=\"http://www.openstreetmap.org/\">OpenStreetMap.org</a> and its contributors; <a href=\"http://opendatacommons.org/licenses/odbl/\">Open Database License</a>"; |
47
|
|
|
} else if (m === "OCM") { |
48
|
|
|
g = false; |
49
|
|
|
c = "Map data (C) by <a href=\"http://www.openstreetmap.org/\">OpenStreetMap.org</a> and its contributors; <a href=\"http://opendatacommons.org/licenses/odbl/\">Open Database License</a>, tiles (C) by <a href=\"http://opencyclemap.org\">OpenCycleMap.org</a>"; |
50
|
|
|
} else if (m === "OUTD") { |
51
|
|
|
g = false; |
52
|
|
|
c = "Map data (C) by <a href=\"http://www.openstreetmap.org/\">OpenStreetMap.org</a> and its contributors; <a href=\"http://opendatacommons.org/licenses/odbl/\">Open Database License</a>, tiles (C) by <a href=\"http://www.thunderforest.com/outdoors/\">Thunderforest</a>"; |
53
|
|
|
} else if (m === "TOPO") { |
54
|
|
|
g = false; |
55
|
|
|
c = "Map data (C) by <a href=\"http://www.openstreetmap.org/\">OpenStreetMap.org</a> and its contributors; <a href=\"http://opendatacommons.org/licenses/odbl/\">Open Database License</a>, height data by SRTM, tiles (C) by <a href=\"http://www.opentopomap.org/\">OpenTopoMap</a>"; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
this.m_div.innerHTML = c; |
59
|
|
|
|
60
|
|
|
if (g) { |
61
|
|
|
$(".gmnoprint a, .gmnoprint span, .gm-style-cc").css("display", "block"); |
62
|
|
|
$("a[href*='maps.google.com/maps']").show(); |
63
|
|
|
this.m_map.setOptions({streetViewControl: true}); |
64
|
|
|
} else { |
65
|
|
|
// hide logo for non-g-maps |
66
|
|
|
$("a[href*='maps.google.com/maps']").hide(); |
67
|
|
|
// hide term-of-use for non-g-maps |
68
|
|
|
$(".gmnoprint a, .gmnoprint span, .gm-style-cc").css("display", "none"); |
69
|
|
|
this.m_map.setOptions({streetViewControl: false}); |
70
|
|
|
} |
71
|
|
|
}; |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
Attribution.forceUpdate = function () { |
75
|
|
|
'use strict'; |
76
|
|
|
|
77
|
|
|
var self = this; |
78
|
|
|
|
79
|
|
|
this.update(); |
80
|
|
|
google.maps.event.addListenerOnce(this.m_map, 'idle', function () { |
81
|
|
|
self.update(); |
82
|
|
|
}); |
83
|
|
|
setTimeout(function () { |
84
|
|
|
self.update(); |
85
|
|
|
}, 1000); |
86
|
|
|
}; |
87
|
|
|
|