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 nonGoogleMapAttribution = { |
41
|
|
|
"OSM": "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>", |
42
|
|
|
"OSM/DE": "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>", |
43
|
|
|
"OCM": "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>", |
44
|
|
|
"OUTD": "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>", |
45
|
|
|
"TOPO": "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>" |
46
|
|
|
}, |
47
|
|
|
a = nonGoogleMapAttribution[this.m_map.getMapTypeId()]; |
48
|
|
|
|
49
|
|
|
if (a !== undefined) { |
50
|
|
|
// non google map -> hide google stuff |
51
|
|
|
this.m_div.innerHTML = a; |
52
|
|
|
$("a[href*='maps.google.com/maps']").hide(); |
53
|
|
|
$(".gmnoprint a, .gmnoprint span, .gm-style-cc").css("display", "none"); |
54
|
|
|
this.m_map.setOptions({streetViewControl: false}); |
55
|
|
|
} else { |
56
|
|
|
// google map -> show google stuff |
57
|
|
|
this.m_div.innerHTML = ""; |
58
|
|
|
$(".gmnoprint a, .gmnoprint span, .gm-style-cc").css("display", "block"); |
59
|
|
|
$("a[href*='maps.google.com/maps']").show(); |
60
|
|
|
this.m_map.setOptions({streetViewControl: true}); |
61
|
|
|
} |
62
|
|
|
}; |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
Attribution.forceUpdate = function () { |
66
|
|
|
'use strict'; |
67
|
|
|
|
68
|
|
|
var self = this; |
69
|
|
|
|
70
|
|
|
this.update(); |
71
|
|
|
google.maps.event.addListenerOnce(this.m_map, 'idle', function () { |
72
|
|
|
self.update(); |
73
|
|
|
}); |
74
|
|
|
setTimeout(function () { |
75
|
|
|
self.update(); |
76
|
|
|
}, 1000); |
77
|
|
|
}; |
78
|
|
|
|