-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.js
117 lines (97 loc) · 3.37 KB
/
map.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
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
/*
This file is part of FacilMap.
FacilMap is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FacilMap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with FacilMap. If not, see <http://www.gnu.org/licenses/>.
Obtain the source code from http://gitorious.org/facilmap.
*/
(function(fm, ol, $) {
window.initMap = function()
{
window.mapObject = new fm.Map("map");
// Readd keyboard control without onlyOnMouseOver setting, as the map is full-screen
var keyboardControl = mapObject.getControlsByClass("FacilMap.Control.KeyboardDefaults")[0];
if(keyboardControl)
{
keyboardControl.deactivate();
mapObject.removeControl(keyboardControl);
}
mapObject.addControl(new fm.Control.KeyboardDefaults({ onlyOnMouseOver : false }));
mapObject.addAllAvailableLayers();
mapObject.addLayer(new fm.Layer.CoordinateGrid(null, { visibility: false, permalinkName: "grid" }));
var activeTool = null;
var cookies = document.cookie.split(/;\s*/);
for(var i=0; i<cookies.length; i++)
{
var cookie = cookies[i].split("=");
if(cookie[0] == "fmTool")
{
activeTool = decodeURIComponent(cookie[1]);
break;
}
}
mapObject.addControl(new fm.Control.GeoLocation());
mapObject.addControl(new fm.Control.Search({ permalinkName : "s" }));
mapObject.addControl(new FacilMap.Control.ToolsMenu.Default());
var historyStateHandler = new fm.Control.HistoryStateHandler({ autoActivate: true, prefixWithMapId: false });
// Patch q parameter for searching
historyStateHandler.stateHandler.getState = function() {
var obj = fm.HistoryStateHandler.prototype.getState.apply(this, arguments);
if(obj.q)
{
if(!obj.c) obj.c = { };
if(!obj.c.s) obj.c.s = { };
if(typeof obj.q == "string") {
var q = obj.q.split(/\s+to\s+/i);
if(q.length == 1)
obj.c.s.query = q[0];
else
obj.c.s.query = q;
} else {
obj.c.s.query = obj.q;
}
if(obj.lon == undefined && obj.lat == undefined && obj.zoom == undefined)
obj.c.s.zoom = "1";
delete obj.q;
}
return obj;
};
historyStateHandler.stateHandler.setState = function(obj) {
if(obj && obj.c && obj.c.s) {
if(obj.c.s.query != null) {
obj.q = obj.c.s.query;
delete obj.c.s.query;
} else if(obj.c.s.from != null && obj.c.s.to != null) {
obj.q = obj.c.s.from+" to "+obj.c.s.to;
delete obj.c.s.from;
delete obj.c.s.to;
}
}
fm.HistoryStateHandler.prototype.setState.apply(this, [ obj ]);
};
mapObject.addControl(historyStateHandler);
$(".olMap .fmControlSearch .from").attr("name", "q");
$(".olControlPanel").mouseover(
function(){ fm.Util.changeOpacity(this, 1); }
).mouseout(
function(){ fm.Util.changeOpacity(this, 0.5); }
).mouseout();
}
ol.Lang.en = ol.Util.extend(ol.Lang.en, {
"Move map" : "Move map",
"OpenStreetBugs" : "OpenStreetBugs",
"Markers" : "Markers"
});
ol.Lang.de = ol.Util.extend(ol.Lang.de, {
"Move map" : "Karte verschieben",
"OpenStreetBugs" : "OpenStreetBugs",
"Markers" : "Marker"
});
})(FacilMap, OpenLayers, FacilMap.$);