annotate markers.js @ 296:625cac7c230d gmap2

Use CSS class instead of direct style / background color manipulation.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 19 Nov 2016 02:27:01 +0200
parents 5c15b45947f2
children 87a17b1fccb5
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 {
175
a1a725a9541d Fix panning to marker.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
53 pmap.panTo(pmapMarkers[i].getPosition());
137
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
54 setTimeout("pmapShowInfo("+ i +")", 1000);
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
55 }
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
56
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
57
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
58 function pmapShowInfo(i)
c7a141d5ce39 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
59 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
60 google.maps.event.trigger(pmapMarkers[i], "click");
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
61 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
62
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
63
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
64 function pmapLocGetLocationType(flags, def)
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
65 {
205
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
66 switch (flags & LOCF_M_MASK)
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
67 {
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
68 case LOCF_M_CITY: return "city";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
69 case LOCF_M_PCITY: return "pcity";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
70 default:
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
71 switch (flags & LOCF_T_MASK)
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
72 {
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
73 case LOCF_T_SHRINE: return "shrine";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
74 case LOCF_T_GUILD: return "guild";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
75 case LOCF_T_SS: return "ss";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
76 case LOCF_T_MONSTER: return "monster";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
77 case LOCF_T_TRAINER: return "trainer";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
78 case LOCF_T_FORT: return "fort";
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
79 }
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
80 break;
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
81 }
653c3355bb1f Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
82 return def ? def : "default";
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
83 }
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
84
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
85
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
86 function pmapCreateMarker(m, mclass)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
87 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
88 type = pmapLocGetLocationType(m["flags"], m["type"]);
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
89 if (m["name"].indexOf('FERRY') == 0)
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
90 type = "ferry";
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
91
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
92 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
93
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
94 if (m["flags"] & LOCF_CLOSED)
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
95 pname += " (CLOSED)";
189
6472cf413478 Adjust marker names.
Matti Hamalainen <ccr@tnsp.org>
parents: 186
diff changeset
96
182
d314c48d16a9 Make markers with labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
97 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
98 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
99 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
100 icon: pmapIcons[type],
182
d314c48d16a9 Make markers with labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
101 draggable: false,
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
102 labelContent: m["name"],
217
7a90c25dfe2e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 210
diff changeset
103 labelAnchor: new google.maps.Point(25, 0),
182
d314c48d16a9 Make markers with labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
104 labelClass: "labels",
d314c48d16a9 Make markers with labels.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
105 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
106 });
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
107
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
108 google.maps.event.addListener(marker, "click", function()
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
109 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
110 pmapInfoWindow.setContent("<div class=\"infowin\">"+ m["html"] +"</div>");
176
d68111417b8e Fix opening of infowindow.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
111 pmapInfoWindow.open(pmap, this);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
112 });
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
113
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
114 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
115 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
116 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
117
184
fc2c2385049b Make map markers change visibility with selections as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
118 pmapMarkers[pmapMIndex] = marker;
223
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
119 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
120 pmapMIndex++;
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
121
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
122 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
123 pmapAreas[type] = [];
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 pmapAreas[type].push(marker);
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
126
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
127 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
128 }
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
129
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
130
222
b88a1e83a667 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 217
diff changeset
131 // Wrapper function for adding markers,
b88a1e83a667 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 217
diff changeset
132 // 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
133 function pmapAddMarkers(mlist, minzoom, maxzoom)
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
134 {
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
135 if (mlist)
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
136 pmapMMgr.addMarkers(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
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
139
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
140 function pmapInitializeMarkers()
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
141 {
224
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
142 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
143
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
144 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
145 {
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
146 pmapInfoWindow.close();
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
147 });
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
148
169
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
149 pmapMMgr = new MarkerManager(pmap);
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
150 google.maps.event.addListener(pmapMMgr, 'loaded', pmapLoadMarkers);
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
151 }
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
152
169
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
153
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
154 function pmapLoadMarkers()
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
155 {
204
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
156 pmapMIndex = 0;
180
662e8b5ec9a5 Close infowindow when needed.
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
157
174
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
158 //
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
159 // Parse regular markers from JSON
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
160 //
169
7c14ab0281ad Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
161 XDownloadUrl("markers.json", function(data, responseCode)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
162 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
163 var markers = JSON.parse(data);
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
164 pmapSideBuiltinHTML = "";
174
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
165 pmapSidePublicHTML = "";
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
166 pmapSidePrivateHTML = "";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
167
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
168 for (var nid = 0; nid < markers.length; nid++)
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
169 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
170 pmapCreateMarker(markers[nid], "builtin");
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
171 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
172
190
d6e16437ee06 Adjust marker zoom level visibility ranges, again.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
173 pmapAddMarkers(pmapAreas["default"], 7, 11);
164
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
174 pmapAddMarkers(pmapAreas["guild"], 6, 11);
190
d6e16437ee06 Adjust marker zoom level visibility ranges, again.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
175 pmapAddMarkers(pmapAreas["shrine"], 6, 11);
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
176 pmapAddMarkers(pmapAreas["trainer"], 6, 11);
164
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
177 pmapAddMarkers(pmapAreas["ferry"], 4, 11);
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
178 pmapAddMarkers(pmapAreas["city"], 4, 11);
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
179
192
260644076c07 Change handling of marker type.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
180 pmapAddMarkers(pmapAreas["monster"], 8, 11);
164
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
181 pmapAddMarkers(pmapAreas["pcity"], 8, 11);
231
c974783065e6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
182 pmapAddMarkers(pmapAreas["fort"], 8, 11);
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
183 pmapMMgr.refresh();
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
184
224
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
185 google.maps.event.trigger(pmap, "foobar");
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
186 document.getElementById("sidecontent").innerHTML = pmapSideBuiltinHTML;
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
187 });
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
188
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
189 //
174
d68af0d5b924 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
190 // Parse tradelane markers from another JSON
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
191 //
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
192 XDownloadUrl("tradelane.json", function(data,responseCode)
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
193 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
194 var markers = JSON.parse(data);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
195
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
196 for (var nid = 0; nid < markers.length; nid++)
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
197 {
196
1307410acf6d Simplify by getting rid of one wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
198 pmapCreateMarker(markers[nid], "tradelane");
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
199 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
200
164
5489c1e24521 Rename things, and add a wrapper function.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
201 pmapAddMarkers(pmapAreas["tradelane"], 5, 11);
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
202 pmapMMgr.refresh();
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
203 });
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
204
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
205 //
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
206 // Create GMap polylines from tradelane line data
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
207 //
210
265debcae71c Rename tradelane polyline datafile.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
208 XDownloadUrl("trlines.json", function(data,responseCode)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
209 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
210 var lines = JSON.parse(data);
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
211
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
212 // Go through array of line elements
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
213 for (var nid = 0; nid < lines.length; nid++)
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
214 {
163
8fd905f81672 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
215 var points = lines[nid];
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
216 var coords = [];
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
217
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
218 // Create polyline points
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
219 for (var npt = 0; npt < points.length; npt++)
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
220 {
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
221 var pt = points[npt];
172
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
222 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
223 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
224
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
225 // 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
226 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
227 path: coords,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
228 strokeColor: "#ffffff",
231
c974783065e6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
229 strokeWeight: 2,
c974783065e6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
230 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
231 });
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
232
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
233 poly.setMap(pmap);
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
234 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
235 });
172
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
236
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
237
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
238 //
163
8fd905f81672 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
239 // Create map control elements
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
240 //
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
241 var str = "<div class=\"vcontinents\">";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
242 var n = 0;
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
243 for (var i = 0; i < pmapContinents.length; i++)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
244 {
226
d151536c9d3d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
245 var c = pmapContinents[i][0];
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
246 str += "<span id=\"sp"+c+"\" class=\"continent\"><a href=\"javascript:pmapToggleVisContinent('"+c+"')\">"+c+"</a></span>\n";
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
247 // if (n == 2) str += "<br />\n";
226
d151536c9d3d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
248 n++;
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
249 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
250
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
251 str += "<span id=\"spall_c\" class=\"continent\"><a href=\"javascript:pmapToggleVisContinent('all_c')\">All</a></span>\n";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
252
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
253 str += "</div>\n";
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
254 str +="<div class=\"vtypes\">\n";
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
255
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
256 n = 0;
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
257 for (var i = 0; i < pmapMarkerTypes.length; i++)
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
258 {
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
259 var q = pmapMarkerTypes[i];
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
260 if (q != null)
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
261 {
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
262 var c = q[1];
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
263 str += "<span id=\"sp"+c+"\" class=\"vtype\"><a href=\"javascript:pmapToggleVisType('"+c+"')\">"+pmapMarkerTypes[i][0]+"</a></span>\n";
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
264 // if (n == 2) str += "<br />\n";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
265 n++;
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
266 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
267 }
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
268
294
5c15b45947f2 Improve stylesheet/dom.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
269 str += "<span id=\"spall_t\" class=\"vtype\"><a href=\"javascript:pmapToggleVisType('all_t')\">All</a></span></div>\n";
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
270
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
271 document.getElementById("controls").innerHTML = str;
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
272
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
273 //
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
274 // Set default states
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
275 //
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
276 pmapSetVisContinent("all_c", true);
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
277 pmapSetVisType("all_t", true);
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
278 pmapUpdateVisible();
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
279 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
280
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
281
223
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
282 function pmapGetMarkerIndexByCoords(mx, my)
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
283 {
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
284 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
285 {
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
286 var m = pmapMarkerInfo[i][2];
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
287 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
288 return i;
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
289 }
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
290
b8dfdc61acbd Add function for finding marker index by global coords.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
291 return null;
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
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
295 //
163
8fd905f81672 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
296 // Map menu / sidebar control code
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
297 //
123
5ffc94212e8f Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 108
diff changeset
298 var markerVisStates = [];
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
299
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
300
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
301 function pmapSetFilterVisState(c, show)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
302 {
123
5ffc94212e8f Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 108
diff changeset
303 markerVisStates[c] = show;
296
625cac7c230d Use CSS class instead of direct style / background color manipulation.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
304 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
305 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
306 elem.classList.remove(!show ? "visible" : "hidden");
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
307 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
308
123
5ffc94212e8f Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 108
diff changeset
309
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
310 function pmapUpdateVisible()
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
311 {
184
fc2c2385049b Make map markers change visibility with selections as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
312 for (var i = 0; i < pmapMarkerInfo.length; i++)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
313 {
204
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
314 var elem = document.getElementById("marker" + i);
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
315 if (elem)
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
316 {
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
317 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
318 elem.style.display = show ? "block" : "none";
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
319 pmapMarkers[i].setVisible(show);
2a2a5e992b9f Fix some errors of accessing nonexisting elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
320 }
67
6fd8670a9243 Improve filtering features.
Matti Hamalainen <ccr@tnsp.org>
parents: 58
diff changeset
321 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
322 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
323
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
324
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
325 function pmapSetVisContinent(c, show)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
326 {
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
327 if (c == "all_c")
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
328 {
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
329 for (var i = 0; i < pmapContinents.length; i++)
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
330 pmapSetFilterVisState(pmapContinents[i][0], show);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
331 }
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
332 pmapSetFilterVisState(c, show);
43
586b6084d89b Cleanups.
ccr@tnsp.org
parents: 40
diff changeset
333 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
334
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
335
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
336 function pmapSetVisType(c, show)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
337 {
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
338 if (c == "all_t")
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
339 {
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
340 for (var i in pmapAreas)
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
341 markerVisStates[i] = show;
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
342
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
343 for (var i = 0; i < pmapMarkerTypes.length; i++)
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
344 pmapSetFilterVisState(pmapMarkerTypes[i][1], show);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
345 }
233
1a89174b7152 Improvements in filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
346 pmapSetFilterVisState(c, show);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
347 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
348
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
349
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
350 function pmapToggleVisContinent(c)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
351 {
234
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
352 var first = true;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
353 if (c == "all_c")
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
354 first = false;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
355 else
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
356 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
357 for (var i = 0; i < pmapContinents.length; i++)
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
358 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
359 var q = pmapContinents[i][0];
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
360 if (!markerVisStates[q])
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 first = false;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
363 break;
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 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
366 }
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 if (first)
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 pmapSetVisContinent("all_c", false);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
371 pmapSetVisContinent(c, true);
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 else
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
374 pmapSetVisContinent(c, !markerVisStates[c]);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
375
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
376 pmapUpdateVisible();
53
de1512fcc3c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
377 }
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
378
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
379
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
380 function pmapToggleVisType(c)
94
887eef05e215 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
381 {
234
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
382 var first = true;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
383 if (c == "all_t")
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
384 first = false;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
385 else
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
386 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
387 for (var i = 0; i < pmapMarkerTypes.length; i++)
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
388 {
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
389 var q = pmapMarkerTypes[i][1];
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
390 if (!markerVisStates[q])
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 first = false;
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
393 break;
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 }
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
396 }
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 if (first)
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 pmapSetVisType("all_t", false);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
401 pmapSetVisType(c, true);
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 else
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
404 pmapSetVisType(c, !markerVisStates[c]);
8a14983244b0 Some more work on filtering controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 233
diff changeset
405
129
d573bb2d9e9f Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
406 pmapUpdateVisible();
53
de1512fcc3c9 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
407 }