annotate markers.js @ 308:c0bac5a78724 gmap2

Change setTimeout() calls to use function format.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 11 Sep 2017 14:36:16 +0300
parents ce52a0b7b281
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
1 // $Id: markers.js 2284 2009-09-21 12:47:20Z jeskko $
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
2
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
3 // Marker types
289
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
4 var LOCF_M_SCENIC1 = (0x000001); /* '?' Scenic marker */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
5 var LOCF_M_SCENIC2 = (0x000002); /* '%' Shrine marker/etc */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
6 var LOCF_M_PCITY = (0x000004); /* 'C' Player city */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
7 var LOCF_M_CITY = (0x000008); /* 'c' City */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
8 var LOCF_M_MASK = (0x00000F);
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
9
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
10 // Location types
289
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
11 var LOCF_T_SHRINE = (0x000010); /* 'S' Raceshrine */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
12 var LOCF_T_GUILD = (0x000020); /* 'G' Guild */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
13 var LOCF_T_SS = (0x000040); /* 'P' Player guild/Secret Society */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
14 var LOCF_T_MONSTER = (0x000080); /* 'M' Special monster */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
15 var LOCF_T_TRAINER = (0x000100); /* 'T' Guild trainer */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
16 var LOCF_T_FORT = (0x000200); /* 'F' Regions fort */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
17 var LOCF_T_MASK = (0x00FFF0);
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
18 var LOCF_MASK = (LOCF_M_MASK | LOCF_T_MASK);
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
19
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
20 // Extra flags
289
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
21 var LOCF_INVIS = (0x010000); /* '-' Invisible marker / Don't show label */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
22 var LOCF_CLOSED = (0x020000); /* '!' Area is CLOSED */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
23 var LOCF_INSTANCED = (0x040000); /* 'I' Location is "instanced" for each player */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
24 var LOCF_INVALID = (0x400000); /* Possibly invalid location */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
25 var LOCF_NOMARKER = (0x800000); /* Location has no marker in mapdata or explicitly defined */
07530034b221 Add instance flag. Not used here yet, tho.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
26 var LOCF_Q_MASK = (0xFF0000);
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
27
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
28
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
29 // List of marker types
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
30 var pmapMarkerTypes =
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
31 [
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
32 ["Guilds", "guild"],
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
33 ["PCities", "pcity"],
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
34 ["Shrines", "shrine"],
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
35 ["Areas", "default"],
231
c974783065e6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
36 ["Mob", "monster"],
232
1706a1bb2a32 Add trainer markers to toggleables.
Matti Hamalainen <ccr@tnsp.org>
parents: 231
diff changeset
37 ["Trn", "trainer"],
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
38 ];
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
39
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
40
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
41 // Some global vars
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
42 var pmapMMgr;
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
43 var pmapAreas = [];
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
44 var pmapMarkers = [];
204
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
45 var pmapMIndex;
184
fc2c2385049b Make map markers change visibility with selections as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
46 var pmapMarkerInfo = [];
174
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
47 var pmapSideBuiltinHTML, pmapSidePublicHTML, pmapSidePrivateHTML;
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
48 var pmapInfoWindow;
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
49
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
50
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
51 function pmapMyClick(i)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
52 {
298
87a17b1fccb5 Zoom to zoom level 8 if we're zoomed less than that.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
53 if (pmap.getZoom() < 8)
87a17b1fccb5 Zoom to zoom level 8 if we're zoomed less than that.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
54 pmap.setZoom(8);
87a17b1fccb5 Zoom to zoom level 8 if we're zoomed less than that.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
55
175
a1a725a9541d Fix panning to marker.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
56 pmap.panTo(pmapMarkers[i].getPosition());
308
c0bac5a78724 Change setTimeout() calls to use function format.
Matti Hamalainen <ccr@tnsp.org>
parents: 299
diff changeset
57 setTimeout(pmapShowInfo, 1000, i);
137
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
58 }
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
59
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
60
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
61 function pmapShowInfo(i)
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
62 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
63 google.maps.event.trigger(pmapMarkers[i], "click");
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
64 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
65
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
66
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
67 function pmapLocGetLocationType(flags, def)
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
68 {
205
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
69 switch (flags & LOCF_M_MASK)
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
70 {
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
71 case LOCF_M_CITY: return "city";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
72 case LOCF_M_PCITY: return "pcity";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
73 default:
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
74 switch (flags & LOCF_T_MASK)
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
75 {
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
76 case LOCF_T_SHRINE: return "shrine";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
77 case LOCF_T_GUILD: return "guild";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
78 case LOCF_T_SS: return "ss";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
79 case LOCF_T_MONSTER: return "monster";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
80 case LOCF_T_TRAINER: return "trainer";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
81 case LOCF_T_FORT: return "fort";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
82 }
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
83 break;
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
84 }
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
85 return def ? def : "default";
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
86 }
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
87
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
88
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
89 function pmapCreateMarker(m, mclass)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
90 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
91 type = pmapLocGetLocationType(m["flags"], m["type"]);
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
92 if (m["name"].indexOf('FERRY') == 0)
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
93 type = "ferry";
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
94
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
95 pname = (type != "default" ? type.toUpperCase()+" " : "") + m["name"];
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
96
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
97 if (m["flags"] & LOCF_CLOSED)
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
98 pname += " (CLOSED)";
189
6472cf413478 Adjust marker names.
Matti Hamalainen <ccr@tnsp.org>
parents: 186
diff changeset
99
182
d314c48d16a9 Make markers with labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
100 var marker = new MarkerWithLabel(
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
101 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
102 position: pmapMapCoordsToLatLng(new google.maps.Point(m["x"] * 2 + 1, m["y"] * 2 + 1), 7),
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
103 icon: pmapIcons[type],
182
d314c48d16a9 Make markers with labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
104 draggable: false,
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
105 labelContent: m["name"],
217
7a90c25dfe2e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 210
diff changeset
106 labelAnchor: new google.maps.Point(25, 0),
182
d314c48d16a9 Make markers with labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
107 labelClass: "labels",
d314c48d16a9 Make markers with labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
108 labelStyle: {opacity: 0.75}
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
109 });
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
110
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
111 google.maps.event.addListener(marker, "click", function()
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
112 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
113 pmapInfoWindow.setContent("<div class=\"infowin\">"+ m["html"] +"</div>");
176
d68111417b8e Fix opening of infowindow.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
114 pmapInfoWindow.open(pmap, this);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
115 });
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
116
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
117 if (mclass == "builtin") pmapSideBuiltinHTML += '<div id="marker'+ pmapMIndex +'" class="c_'+ m["continent"].toLowerCase()+'"><div>&nbsp;</div><a href="javascript:pmapMyClick('+ pmapMIndex +')">'+ pname +'</a></div>';
189
6472cf413478 Adjust marker names.
Matti Hamalainen <ccr@tnsp.org>
parents: 186
diff changeset
118 if (mclass == "private") pmapSidePrivateHTML += '<a href="javascript:pmapMyClick(' + pmapMIndex + ')">' + pname + '</a><br>';
6472cf413478 Adjust marker names.
Matti Hamalainen <ccr@tnsp.org>
parents: 186
diff changeset
119 if (mclass == "public") pmapSidePublicHTML += '<a href="javascript:pmapMyClick(' + pmapMIndex + ')">' + pname + '</a><br>';
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
120
184
fc2c2385049b Make map markers change visibility with selections as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
121 pmapMarkers[pmapMIndex] = marker;
223
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
122 pmapMarkerInfo[pmapMIndex] = [type, m["continent"], m];
184
fc2c2385049b Make map markers change visibility with selections as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
123 pmapMIndex++;
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
124
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
125 if (pmapAreas[type] == undefined)
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
126 pmapAreas[type] = [];
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
127
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
128 pmapAreas[type].push(marker);
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
129
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
130 return marker;
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
131 }
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
132
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
133
222
b88a1e83a667 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 217
diff changeset
134 // Wrapper function for adding markers,
b88a1e83a667 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 217
diff changeset
135 // checks if the array is defined first.
164
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
136 function pmapAddMarkers(mlist, minzoom, maxzoom)
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
137 {
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
138 if (mlist)
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
139 pmapMMgr.addMarkers(mlist, minzoom, maxzoom);
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
140 }
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
141
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
142
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
143 function pmapInitializeMarkers()
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
144 {
224
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
145 pmapInfoWindow = new google.maps.InfoWindow;
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
146
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
147 google.maps.event.addListener(pmap, 'click', function()
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
148 {
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
149 pmapInfoWindow.close();
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
150 });
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
151
169
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
152 pmapMMgr = new MarkerManager(pmap);
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
153 google.maps.event.addListener(pmapMMgr, 'loaded', pmapLoadMarkers);
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
154 }
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
155
169
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
156
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
157 function pmapLoadMarkers()
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
158 {
204
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
159 pmapMIndex = 0;
180
662e8b5ec9a5 Close infowindow when needed.
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
160
174
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
161 //
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
162 // Parse regular markers from JSON
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
163 //
169
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
164 XDownloadUrl("markers.json", function(data, responseCode)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
165 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
166 var markers = JSON.parse(data);
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
167 pmapSideBuiltinHTML = "";
174
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
168 pmapSidePublicHTML = "";
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
169 pmapSidePrivateHTML = "";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
170
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
171 for (var nid = 0; nid < markers.length; nid++)
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
172 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
173 pmapCreateMarker(markers[nid], "builtin");
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
174 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
175
190
d6e16437ee06 Adjust marker zoom level visibility ranges, again.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
176 pmapAddMarkers(pmapAreas["default"], 7, 11);
164
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
177 pmapAddMarkers(pmapAreas["guild"], 6, 11);
190
d6e16437ee06 Adjust marker zoom level visibility ranges, again.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
178 pmapAddMarkers(pmapAreas["shrine"], 6, 11);
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
179 pmapAddMarkers(pmapAreas["trainer"], 6, 11);
164
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
180 pmapAddMarkers(pmapAreas["ferry"], 4, 11);
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
181 pmapAddMarkers(pmapAreas["city"], 4, 11);
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
182
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
183 pmapAddMarkers(pmapAreas["monster"], 8, 11);
164
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
184 pmapAddMarkers(pmapAreas["pcity"], 8, 11);
231
c974783065e6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
185 pmapAddMarkers(pmapAreas["fort"], 8, 11);
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
186 pmapMMgr.refresh();
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
187
224
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
188 google.maps.event.trigger(pmap, "foobar");
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
189 document.getElementById("sidecontent").innerHTML = pmapSideBuiltinHTML;
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
190 });
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
191
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
192 //
174
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
193 // Parse tradelane markers from another JSON
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
194 //
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
195 XDownloadUrl("tradelane.json", function(data,responseCode)
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
196 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
197 var markers = JSON.parse(data);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
198
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
199 for (var nid = 0; nid < markers.length; nid++)
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
200 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
201 pmapCreateMarker(markers[nid], "tradelane");
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
202 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
203
164
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
204 pmapAddMarkers(pmapAreas["tradelane"], 5, 11);
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
205 pmapMMgr.refresh();
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
206 });
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
207
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
208 //
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
209 // Create GMap polylines from tradelane line data
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
210 //
210
265debcae71c Rename tradelane polyline datafile.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
211 XDownloadUrl("trlines.json", function(data,responseCode)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
212 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
213 var lines = JSON.parse(data);
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
214
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
215 // Go through array of line elements
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
216 for (var nid = 0; nid < lines.length; nid++)
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
217 {
163
8fd905f81672 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
218 var points = lines[nid];
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
219 var coords = [];
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
220
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
221 // Create polyline points
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
222 for (var npt = 0; npt < points.length; npt++)
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
223 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
224 var pt = points[npt];
172
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
225 coords.push(pmapMapCoordsToLatLng(new google.maps.Point(pt["x"] * 2 + 1, pt["y"] * 2 + 1), 7));
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
226 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
227
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
228 // Create new polyline and add it to map overlay
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
229 var poly = new google.maps.Polyline({
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
230 path: coords,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
231 strokeColor: "#ffffff",
231
c974783065e6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
232 strokeWeight: 2,
c974783065e6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
233 strokeOpacity: 0.6
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
234 });
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
235
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
236 poly.setMap(pmap);
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
237 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
238 });
172
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
239
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
240
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
241 //
163
8fd905f81672 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
242 // Create map control elements
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
243 //
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
244 var str = "<div class=\"vcontinents\">";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
245 var n = 0;
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
246 for (var i = 0; i < pmapContinents.length; i++)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
247 {
226
d151536c9d3d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
248 var c = pmapContinents[i][0];
299
ce52a0b7b281 Rework the visibility controls DOM and CSS.
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
249 str += "<a id=\"sp"+c+"\" class=\"continent\" href=\"javascript:pmapToggleVisContinent('"+c+"')\">"+c+"</a>\n";
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
250 // if (n == 2) str += "<br />\n";
226
d151536c9d3d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
251 n++;
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
252 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
253
299
ce52a0b7b281 Rework the visibility controls DOM and CSS.
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
254 str += "<a id=\"spall_c\" class=\"continent\" href=\"javascript:pmapToggleVisContinent('all_c')\">All</a>\n";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
255
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
256 str += "</div>\n";
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
257 str +="<div class=\"vtypes\">\n";
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
258
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
259 n = 0;
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
260 for (var i = 0; i < pmapMarkerTypes.length; i++)
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
261 {
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
262 var q = pmapMarkerTypes[i];
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
263 if (q != null)
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
264 {
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
265 var c = q[1];
299
ce52a0b7b281 Rework the visibility controls DOM and CSS.
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
266 str += "<a id=\"sp"+c+"\" class=\"vtype\" href=\"javascript:pmapToggleVisType('"+c+"')\">"+pmapMarkerTypes[i][0]+"</a>\n";
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
267 // if (n == 2) str += "<br />\n";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
268 n++;
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
269 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
270 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
271
299
ce52a0b7b281 Rework the visibility controls DOM and CSS.
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
272 str += "<a id=\"spall_t\" class=\"vtype\" href=\"javascript:pmapToggleVisType('all_t')\">All</a></div>\n";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
273
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
274 document.getElementById("controls").innerHTML = str;
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
275
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
276 //
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
277 // Set default states
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
278 //
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
279 pmapSetVisContinent("all_c", true);
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
280 pmapSetVisType("all_t", true);
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
281 pmapUpdateVisible();
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
282 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
283
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
284
223
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
285 function pmapGetMarkerIndexByCoords(mx, my)
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
286 {
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
287 for (var i = 0; i < pmapMarkerInfo.length; i++)
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
288 {
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
289 var m = pmapMarkerInfo[i][2];
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
290 if (m["x"] == mx && m["y"] == my)
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
291 return i;
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
292 }
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
293
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
294 return null;
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
295 }
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
296
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
297
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
298 //
163
8fd905f81672 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
299 // Map menu / sidebar control code
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
300 //
123
5ffc94212e8f Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 108
diff changeset
301 var markerVisStates = [];
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
302
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
303
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
304 function pmapSetFilterVisState(c, show)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
305 {
123
5ffc94212e8f Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 108
diff changeset
306 markerVisStates[c] = show;
296
625cac7c230d Use CSS class instead of direct style / background color manipulation.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
307 var elem = document.getElementById("sp" + c);
625cac7c230d Use CSS class instead of direct style / background color manipulation.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
308 elem.classList.add(show ? "visible" : "hidden");
625cac7c230d Use CSS class instead of direct style / background color manipulation.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
309 elem.classList.remove(!show ? "visible" : "hidden");
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
310 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
311
123
5ffc94212e8f Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 108
diff changeset
312
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
313 function pmapUpdateVisible()
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
314 {
184
fc2c2385049b Make map markers change visibility with selections as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
315 for (var i = 0; i < pmapMarkerInfo.length; i++)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
316 {
204
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
317 var elem = document.getElementById("marker" + i);
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
318 if (elem)
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
319 {
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
320 var show = markerVisStates[pmapMarkerInfo[i][0]] && markerVisStates[pmapMarkerInfo[i][1]];
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
321 elem.style.display = show ? "block" : "none";
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
322 pmapMarkers[i].setVisible(show);
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
323 }
67
6fd8670a9243 Improve filtering features.
Matti Hamalainen <ccr@tnsp.org>
parents: 58
diff changeset
324 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
325 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
326
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
327
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
328 function pmapSetVisContinent(c, show)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
329 {
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
330 if (c == "all_c")
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
331 {
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
332 for (var i = 0; i < pmapContinents.length; i++)
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
333 pmapSetFilterVisState(pmapContinents[i][0], show);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
334 }
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
335 pmapSetFilterVisState(c, show);
43
586b6084d89b Cleanups.
ccr@tnsp.org
parents: 40
diff changeset
336 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
337
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
338
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
339 function pmapSetVisType(c, show)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
340 {
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
341 if (c == "all_t")
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
342 {
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
343 for (var i in pmapAreas)
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
344 markerVisStates[i] = show;
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
345
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
346 for (var i = 0; i < pmapMarkerTypes.length; i++)
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
347 pmapSetFilterVisState(pmapMarkerTypes[i][1], show);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
348 }
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
349 pmapSetFilterVisState(c, show);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
350 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
351
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
352
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
353 function pmapToggleVisContinent(c)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
354 {
234
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
355 var first = true;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
356 if (c == "all_c")
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
357 first = false;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
358 else
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
359 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
360 for (var i = 0; i < pmapContinents.length; i++)
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
361 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
362 var q = pmapContinents[i][0];
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
363 if (!markerVisStates[q])
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
364 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
365 first = false;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
366 break;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
367 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
368 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
369 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
370
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
371 if (first)
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
372 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
373 pmapSetVisContinent("all_c", false);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
374 pmapSetVisContinent(c, true);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
375 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
376 else
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
377 pmapSetVisContinent(c, !markerVisStates[c]);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
378
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
379 pmapUpdateVisible();
53
de1512fcc3c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
380 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
381
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
382
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
383 function pmapToggleVisType(c)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
384 {
234
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
385 var first = true;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
386 if (c == "all_t")
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
387 first = false;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
388 else
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
389 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
390 for (var i = 0; i < pmapMarkerTypes.length; i++)
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
391 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
392 var q = pmapMarkerTypes[i][1];
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
393 if (!markerVisStates[q])
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
394 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
395 first = false;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
396 break;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
397 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
398 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
399 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
400
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
401 if (first)
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
402 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
403 pmapSetVisType("all_t", false);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
404 pmapSetVisType(c, true);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
405 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
406 else
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
407 pmapSetVisType(c, !markerVisStates[c]);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
408
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
409 pmapUpdateVisible();
53
de1512fcc3c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
410 }