Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | die( '<b>Error:</b> You need to have <a href="http://www.mediawiki.org/wiki/Extension:Validator">Validator</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Maps">Maps</a>.<br />' ); |
38 | 38 | } |
39 | 39 | else { |
40 | | - define( 'Maps_VERSION', '0.7.5' ); |
| 40 | + define( 'Maps_VERSION', '0.7.6 alpha' ); |
41 | 41 | |
42 | 42 | // The different coordinate notations. |
43 | 43 | define( 'Maps_COORDS_FLOAT', 'float' ); |
— | — | @@ -101,6 +101,7 @@ |
102 | 102 | $wgAutoloadClasses['MapsParamDimension'] = $manDir . 'Maps_ParamDimension.php'; |
103 | 103 | $wgAutoloadClasses['MapsParamGeoService'] = $manDir . 'Maps_ParamGeoService.php'; |
104 | 104 | $wgAutoloadClasses['MapsParamImage'] = $manDir . 'Maps_ParamImage.php'; |
| 105 | + $wgAutoloadClasses['MapsParamImageFull'] = $manDir . 'Maps_ParamImageFull.php'; |
105 | 106 | $wgAutoloadClasses['MapsParamLocation'] = $manDir . 'Maps_ParamLocation.php'; |
106 | 107 | $wgAutoloadClasses['MapsParamService'] = $manDir . 'Maps_ParamService.php'; |
107 | 108 | $wgAutoloadClasses['MapsParamZoom'] = $manDir . 'Maps_ParamZoom.php'; |
Index: trunk/extensions/Maps/includes/services/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -46,6 +46,8 @@ |
47 | 47 | global $egMapsGoogleMapsType, $egMapsGoogleMapsTypes, $egMapsGoogleAutozoom, $egMapsGMapControls, $egMapsGMapOverlays; |
48 | 48 | |
49 | 49 | $params['zoom']->addCriteria( new CriterionInRange( 0, 20 ) ); |
| 50 | + // Default zoom is not necessary if kml is set |
| 51 | + //$params['zoom']->setDefault(null); |
50 | 52 | $params['zoom']->setDefault( self::getDefaultZoom() ); |
51 | 53 | |
52 | 54 | $params['controls'] = new ListParameter( 'controls' ); |
— | — | @@ -89,8 +91,11 @@ |
90 | 92 | |
91 | 93 | $params['kml'] = new ListParameter( 'kml' ); |
92 | 94 | $params['kml']->setDefault( array() ); |
93 | | - $params['kml']->addManipulations( new ParamManipulationImplode( ',', "'" ) ); |
| 95 | + //do both translation and imploding |
| 96 | + $myKMLManips = array(new MapsParamImageFull(), new ParamManipulationImplode( ',', "'" )); |
| 97 | + $params['kml']->addManipulations( $myKMLManips); |
94 | 98 | |
| 99 | + |
95 | 100 | $params['overlays'] = new ListParameter( 'overlays' ); |
96 | 101 | $params['overlays']->setDefault( $egMapsGMapOverlays ); |
97 | 102 | $params['overlays']->addCriteria( new CriterionGoogleOverlay( self::$overlayData ) ); |
Index: trunk/extensions/Maps/includes/services/GoogleMaps/GoogleMapFunctions.js |
— | — | @@ -1,83 +1,87 @@ |
2 | | - /** |
3 | | - * Javascript functions for Google Maps functionality in Maps. |
4 | | - * |
5 | | - * @file GoogleMapFunctions.js |
6 | | - * @ingroup MapsGoogleMaps |
7 | | - * |
8 | | - * @author Robert Buzink |
9 | | - * @author Yaron Koren |
10 | | - * @author Jeroen De Dauw |
11 | | - */ |
| 2 | +/** |
| 3 | + * Javascript functions for Google Maps functionality in Maps. |
| 4 | + * |
| 5 | + * @file GoogleMapFunctions.js |
| 6 | + * @ingroup MapsGoogleMaps |
| 7 | + * |
| 8 | + * @author Robert Buzink |
| 9 | + * @author Yaron Koren |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
12 | 12 | |
13 | | -var GOverlays = [ |
14 | | - new GLayer("com.panoramio.all"), |
15 | | - new GLayer("com.youtube.all"), |
16 | | - new GLayer("org.wikipedia.en"), |
17 | | - new GLayer("com.google.webcams") |
18 | | -]; |
| 13 | +var GOverlays = [ new GLayer("com.panoramio.all"), |
| 14 | + new GLayer("com.youtube.all"), new GLayer("org.wikipedia.en"), |
| 15 | + new GLayer("com.google.webcams") ]; |
19 | 16 | |
20 | | - |
21 | 17 | /** |
22 | 18 | * Returns GMarker object on the provided location. It will show a popup baloon |
23 | 19 | * with title and label when clicked, if either of these is set. |
24 | 20 | */ |
25 | | -function createGMarker( markerData ) { |
| 21 | +function createGMarker(markerData) { |
26 | 22 | var marker; |
27 | | - |
28 | | - if ( markerData.icon != '' ) { |
29 | | - var iconObj = new GIcon( G_DEFAULT_ICON ); |
| 23 | + |
| 24 | + if (markerData.icon != '') { |
| 25 | + var iconObj = new GIcon(G_DEFAULT_ICON); |
30 | 26 | iconObj.image = markerData.icon; |
31 | 27 | |
32 | | - |
33 | 28 | var newimg = new Image(); |
34 | 29 | newimg.src = markerData.icon; |
35 | | - |
36 | | - // Only do these things when there is an actual width, which there won,t the first time the image is loaded. |
37 | | - // FIXME: this means the image won't have it's correct size when it differs from the default on first load! |
38 | | - if ( newimg.width > 0 ) { |
| 30 | + |
| 31 | + // Only do these things when there is an actual width, which there won,t |
| 32 | + // the first time the image is loaded. |
| 33 | + // FIXME: this means the image won't have it's correct size when it |
| 34 | + // differs from the default on first load! |
| 35 | + if (newimg.width > 0) { |
39 | 36 | /* Determine size of icon and pass it in */ |
40 | 37 | iconObj.iconSize.width = newimg.width; |
41 | 38 | iconObj.iconSize.height = newimg.height; |
42 | | - iconObj.shadow = null; |
43 | | - |
| 39 | + iconObj.shadow = null; |
| 40 | + |
44 | 41 | /* Anchor the icon on bottom middle */ |
45 | 42 | var anchor = new GPoint(); |
46 | | - anchor.x = Math.floor( newimg.width / 2 ); |
| 43 | + anchor.x = Math.floor(newimg.width / 2); |
47 | 44 | anchor.y = newimg.height; |
48 | | - iconObj.iconAnchor = anchor; |
| 45 | + iconObj.iconAnchor = anchor; |
49 | 46 | } |
50 | 47 | |
51 | | - marker = new GMarker( markerData.point, { icon: iconObj } ); |
| 48 | + marker = new GMarker(markerData.point, { |
| 49 | + icon : iconObj |
| 50 | + }); |
52 | 51 | } else { |
53 | | - marker = new GMarker( markerData.point ); |
| 52 | + marker = new GMarker(markerData.point); |
54 | 53 | } |
55 | | - |
56 | | - if ( ( markerData.title + markerData.label ).length != '' ) { |
57 | | - var bothTxtAreSet = markerData.title.length != '' && markerData.label.length != ''; |
58 | | - var popupText = bothTxtAreSet ? '<b>' + markerData.title + '</b><hr />' + markerData.label : markerData.title + markerData.label; |
59 | | - popupText = '<div style="overflow:auto;max-height:130px;">' + popupText + '</div>'; |
60 | 54 | |
61 | | - GEvent.addListener(marker, 'click', |
62 | | - function() { |
63 | | - marker.openInfoWindowHtml(popupText, {maxWidth:350}); |
64 | | - } |
65 | | - ); |
| 55 | + if ((markerData.title + markerData.label).length != '') { |
| 56 | + var bothTxtAreSet = markerData.title.length != '' |
| 57 | + && markerData.label.length != ''; |
| 58 | + var popupText = bothTxtAreSet ? '<b>' + markerData.title + '</b><hr />' |
| 59 | + + markerData.label : markerData.title + markerData.label; |
| 60 | + popupText = '<div style="overflow:auto;max-height:130px;">' + popupText |
| 61 | + + '</div>'; |
| 62 | + |
| 63 | + GEvent.addListener(marker, 'click', function() { |
| 64 | + marker.openInfoWindowHtml(popupText, { |
| 65 | + maxWidth : 350 |
| 66 | + }); |
| 67 | + }); |
66 | 68 | } |
67 | 69 | |
68 | 70 | return marker; |
69 | 71 | } |
70 | 72 | |
71 | 73 | /** |
72 | | - * Returns GMap2 object with the provided properties and markers. |
73 | | - * This is done by setting the map centre and size, and passing the arguments to function createGoogleMap. |
| 74 | + * Returns GMap2 object with the provided properties and markers. This is done |
| 75 | + * by setting the map centre and size, and passing the arguments to function |
| 76 | + * createGoogleMap. |
74 | 77 | */ |
75 | 78 | function initializeGoogleMap(mapName, mapOptions, markers) { |
76 | 79 | if (GBrowserIsCompatible()) { |
77 | | - mapOptions.centre = (mapOptions.lat != null && mapOptions.lon != null) ? new GLatLng(mapOptions.lat, mapOptions.lon) : null; |
78 | | - //mapOptions.size = new GSize(mapOptions.width, mapOptions.height); |
79 | | - return createGoogleMap(mapName, mapOptions, markers); |
80 | | - } |
81 | | - else { |
| 80 | + mapOptions.centre = (mapOptions.lat != null && mapOptions.lon != null) ? new GLatLng( |
| 81 | + mapOptions.lat, mapOptions.lon) |
| 82 | + : null; |
| 83 | + // mapOptions.size = new GSize(mapOptions.width, mapOptions.height); |
| 84 | + return createGoogleMap(mapName, mapOptions, markers); |
| 85 | + } else { |
82 | 86 | return false; |
83 | 87 | } |
84 | 88 | } |
— | — | @@ -89,119 +93,229 @@ |
90 | 94 | var mapElement = document.getElementById(mapName); |
91 | 95 | var typesContainType = false; |
92 | 96 | |
93 | | - for (var i = 0; i < mapOptions.types.length; i++) { |
94 | | - if (mapOptions.types[i] == mapOptions.type) typesContainType = true; |
| 97 | + for ( var i = 0; i < mapOptions.types.length; i++) { |
| 98 | + if (mapOptions.types[i] == mapOptions.type) |
| 99 | + typesContainType = true; |
95 | 100 | } |
96 | 101 | |
97 | | - if (! typesContainType) mapOptions.types.push(mapOptions.type); |
| 102 | + if (!typesContainType) |
| 103 | + mapOptions.types.push(mapOptions.type); |
98 | 104 | |
99 | | - var map = new GMap2(mapElement, {mapTypes: mapOptions.types}); |
| 105 | + var map = new GMap2(mapElement, { |
| 106 | + mapTypes : mapOptions.types |
| 107 | + }); |
100 | 108 | map.name = mapName; |
101 | 109 | |
102 | | - map.setMapType(mapOptions.type); |
| 110 | + map.setMapType(mapOptions.type); |
103 | 111 | |
104 | 112 | var hasSearchBar = false; |
105 | | - |
106 | | - for ( i = mapOptions.controls.length - 1; i >= 0; i-- ) { |
107 | | - if ( mapOptions.controls[i] == 'searchbar' ) { |
| 113 | + |
| 114 | + for (i = mapOptions.controls.length - 1; i >= 0; i--) { |
| 115 | + if (mapOptions.controls[i] == 'searchbar') { |
108 | 116 | hasSearchBar = true; |
109 | 117 | break; |
110 | 118 | } |
111 | 119 | } |
112 | | - |
113 | | - // List of GControls: http://code.google.com/apis/maps/documentation/reference.html#GControl |
114 | | - for ( i = 0; i < mapOptions.controls.length; i++ ) { |
115 | | - if ( mapOptions.controls[i].toLowerCase() == 'auto' ) { |
116 | | - if ( mapElement.offsetHeight > 75 ) mapOptions.controls[i] = mapElement.offsetHeight > 320 ? 'large' : 'small'; |
117 | | - } |
118 | | - |
119 | | - switch ( mapOptions.controls[i] ) { |
120 | | - case 'large' : |
121 | | - map.addControl( new GLargeMapControl3D() ); |
122 | | - break; |
123 | | - case 'small' : |
124 | | - map.addControl( new GSmallZoomControl3D() ); |
125 | | - break; |
126 | | - case 'large-original' : |
127 | | - map.addControl( new GLargeMapControl() ); |
128 | | - break; |
129 | | - case 'small-original' : |
130 | | - map.addControl( new GSmallMapControl() ); |
131 | | - break; |
132 | | - case 'zoom' : |
133 | | - map.addControl( new GSmallZoomControl() ); |
134 | | - break; |
135 | | - case 'type' : |
136 | | - map.addControl( new GMapTypeControl() ); |
137 | | - break; |
138 | | - case 'type-menu' : |
139 | | - map.addControl( new GMenuMapTypeControl() ); |
140 | | - break; |
141 | | - case 'overlays' : |
142 | | - map.addControl( new MoreControl() ); |
143 | | - break; |
144 | | - case 'overview' : case 'overview-map' : |
145 | | - map.addControl( new GOverviewMapControl() ); |
146 | | - break; |
147 | | - case 'scale' : |
148 | | - if ( hasSearchBar ) { |
149 | | - map.addControl( new GScaleControl(), new GControlPosition( G_ANCHOR_BOTTOM_LEFT, new GSize( 5,37 ) ) ); |
150 | | - } |
151 | | - else { |
152 | | - map.addControl( new GScaleControl() ); |
153 | | - } |
154 | | - break; |
155 | | - case 'nav-label' : case 'nav' : |
156 | | - map.addControl( new GNavLabelControl() ); |
157 | | - break; |
158 | | - case 'searchbar' : |
159 | | - map.enableGoogleBar(); |
160 | | - break; |
| 120 | + |
| 121 | + // List of GControls: |
| 122 | + // http://code.google.com/apis/maps/documentation/reference.html#GControl |
| 123 | + for (i = 0; i < mapOptions.controls.length; i++) { |
| 124 | + if (mapOptions.controls[i].toLowerCase() == 'auto') { |
| 125 | + if (mapElement.offsetHeight > 75) |
| 126 | + mapOptions.controls[i] = mapElement.offsetHeight > 320 ? 'large' |
| 127 | + : 'small'; |
161 | 128 | } |
162 | | - } |
163 | 129 | |
164 | | - var bounds = ((mapOptions.zoom == null || mapOptions.centre == null) && markers.length > 1) ? new GLatLngBounds() : null; |
| 130 | + switch (mapOptions.controls[i]) { |
| 131 | + case 'large': |
| 132 | + map.addControl(new GLargeMapControl3D()); |
| 133 | + break; |
| 134 | + case 'small': |
| 135 | + map.addControl(new GSmallZoomControl3D()); |
| 136 | + break; |
| 137 | + case 'large-original': |
| 138 | + map.addControl(new GLargeMapControl()); |
| 139 | + break; |
| 140 | + case 'small-original': |
| 141 | + map.addControl(new GSmallMapControl()); |
| 142 | + break; |
| 143 | + case 'zoom': |
| 144 | + map.addControl(new GSmallZoomControl()); |
| 145 | + break; |
| 146 | + case 'type': |
| 147 | + map.addControl(new GMapTypeControl()); |
| 148 | + break; |
| 149 | + case 'type-menu': |
| 150 | + map.addControl(new GMenuMapTypeControl()); |
| 151 | + break; |
| 152 | + case 'overlays': |
| 153 | + map.addControl(new MoreControl()); |
| 154 | + break; |
| 155 | + case 'overview': |
| 156 | + case 'overview-map': |
| 157 | + map.addControl(new GOverviewMapControl()); |
| 158 | + break; |
| 159 | + case 'scale': |
| 160 | + if (hasSearchBar) { |
| 161 | + map.addControl(new GScaleControl(), new GControlPosition( |
| 162 | + G_ANCHOR_BOTTOM_LEFT, new GSize(5, 37))); |
| 163 | + } else { |
| 164 | + map.addControl(new GScaleControl()); |
| 165 | + } |
| 166 | + break; |
| 167 | + case 'nav-label': |
| 168 | + case 'nav': |
| 169 | + map.addControl(new GNavLabelControl()); |
| 170 | + break; |
| 171 | + case 'searchbar': |
| 172 | + map.enableGoogleBar(); |
| 173 | + break; |
| 174 | + } |
| 175 | + } |
165 | 176 | |
166 | | - for ( i = markers.length - 1; i >= 0; i-- ) { |
167 | | - var marker = markers[i]; |
168 | | - marker.point = new GLatLng( marker.lat, marker.lon ); |
169 | | - map.addOverlay( createGMarker( marker ) ); |
170 | | - if ( bounds != null ) bounds.extend( marker.point ); |
| 177 | + // Get center and zoom |
| 178 | + var myCenter = null; |
| 179 | + var myZoom = null; |
| 180 | + if (mapOptions.centre != null) { |
| 181 | + myCenter = mapOptions.centre; |
171 | 182 | } |
| 183 | + if (mapOptions.zoom != null) { |
| 184 | + myZoom = mapOptions.zoom; |
| 185 | + } |
172 | 186 | |
173 | | - if (bounds != null) { |
174 | | - map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); |
| 187 | + // possibly, create bounds from markers |
| 188 | + if ((mapOptions.zoom == null || mapOptions.centre == null) |
| 189 | + && markers.length >= 1) { |
| 190 | + var bounds = new GLatLngBounds(); |
| 191 | + |
| 192 | + for (i = markers.length - 1; i >= 0; i--) { |
| 193 | + var marker = markers[i]; |
| 194 | + marker.point = new GLatLng(marker.lat, marker.lon); |
| 195 | + map.addOverlay(createGMarker(marker)); |
| 196 | + bounds.extend(marker.point); |
| 197 | + } |
| 198 | + if (myCenter == null) { |
| 199 | + myCenter = bounds.getCenter(); |
| 200 | + } |
| 201 | + if (myZoom == null) { |
| 202 | + myZoom = map.getBoundsZoomLevel(bounds); |
| 203 | + } |
175 | 204 | } |
176 | 205 | |
177 | | - if (mapOptions.centre != null) map.setCenter(mapOptions.centre); |
178 | | - if (mapOptions.zoom != null) map.setZoom(mapOptions.zoom); |
179 | | - |
180 | | - if (mapOptions.scrollWheelZoom) map.enableScrollWheelZoom(); |
| 206 | + //TODO: retrieve standard values dynamically? |
| 207 | + if ((myCenter == null || myZoom == null) || ((myCenter.lat() == 0 && myCenter.lng() == 0) && myZoom == 14)) { |
| 208 | + map.setCenter(new GLatLng(0, 0), 14); |
| 209 | + map.isDefaultBound = true; |
| 210 | + } else { |
| 211 | + map.setCenter(myCenter, myZoom); |
| 212 | + map.isDefaultBound = false; |
| 213 | + } |
181 | 214 | |
| 215 | + // other options of map |
| 216 | + if (mapOptions.scrollWheelZoom) |
| 217 | + map.enableScrollWheelZoom(); |
| 218 | + |
182 | 219 | map.enableContinuousZoom(); |
183 | | - |
| 220 | + |
| 221 | + // We add Listener for goDraw event |
| 222 | + GEvent.addListener(map, "goDraw", function() { |
| 223 | + // by now, we have all points from the kml files |
| 224 | + |
| 225 | + var mykmlOverlays = window.GKMLOverlays[map.name]; |
| 226 | + |
| 227 | + var bounds; |
| 228 | + // if center and zoom are set |
| 229 | + if (map.isDefaultBound) { |
| 230 | + // use bounds of first overlay |
| 231 | + bounds = mykmlOverlays[0].getDefaultBounds(); |
| 232 | + } else { |
| 233 | + bounds = map.getBounds(); |
| 234 | + } |
| 235 | + |
| 236 | + for (i = mykmlOverlays.length - 1; i >= 0; i--) { |
| 237 | + var point = mykmlOverlays[i].getDefaultCenter(); |
| 238 | + // extending to the same point should not make a difference |
| 239 | + bounds.extend(point); |
| 240 | + } |
| 241 | + |
| 242 | + map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds)); |
| 243 | + |
| 244 | + }); |
| 245 | + |
184 | 246 | // Code to add KML files. |
185 | 247 | var kmlOverlays = []; |
186 | | - for ( i = mapOptions.kml.length - 1; i >= 0; i-- ) { |
187 | | - kmlOverlays[i] = new GGeoXml( mapOptions.kml[i] ); |
188 | | - map.addOverlay( kmlOverlays[i] ); |
| 248 | + // How many kml files are there, save this. |
| 249 | + if (!window.Gkmlln) { |
| 250 | + window.Gkmlln = new Array(); |
189 | 251 | } |
190 | | - |
| 252 | + window.Gkmlln[mapName] = mapOptions.kml.length; |
| 253 | + // How many kml files have we already loaded? Save this. |
| 254 | + if (!window.Gkmlnr) { |
| 255 | + window.Gkmlnr = new Array(); |
| 256 | + } |
| 257 | + window.Gkmlnr[mapName] = 0; |
| 258 | + for (i = mapOptions.kml.length - 1; i >= 0; i--) { |
| 259 | + // if only names are given |
| 260 | + kmlOverlays[i] = new GGeoXml(mapOptions.kml[i]); |
| 261 | + var myoverlay = kmlOverlays[i]; |
| 262 | + myoverlay.mapName = mapName; |
| 263 | + map.addOverlay(myoverlay); |
| 264 | + |
| 265 | + GEvent.addListener(myoverlay, "load", function() { |
| 266 | + |
| 267 | + // What we only do here is, we count the number of loaded kml |
| 268 | + // overlays |
| 269 | + ++window.Gkmlnr[myoverlay.mapName]; |
| 270 | + if (window.Gkmlnr[myoverlay.mapName] >= window.Gkmlln[myoverlay.mapName]) { |
| 271 | + |
| 272 | + var mymap = window.GMaps[myoverlay.mapName]; |
| 273 | + // we have to make sure that the map is loaded. |
| 274 | + if (mymap.isLoaded()) { |
| 275 | + GEvent.trigger(mymap, "goDraw"); |
| 276 | + } else { |
| 277 | + GEvent.addListener(mymap, "load", function() { |
| 278 | + GEvent.trigger(mymap, "goDraw"); |
| 279 | + }); |
| 280 | + } |
| 281 | + } else { |
| 282 | + return; |
| 283 | + } |
| 284 | + }); |
| 285 | + |
| 286 | + // Make the overlay variable available for other functions |
| 287 | + if (!window.GKMLOverlays) { |
| 288 | + window.GKMLOverlays = new Array(); |
| 289 | + } |
| 290 | + if (!window.GKMLOverlays[mapName]) { |
| 291 | + window.GKMLOverlays[mapName] = new Array(); |
| 292 | + } |
| 293 | + window.GKMLOverlays[mapName][i] = myoverlay; |
| 294 | + } |
| 295 | + |
| 296 | + // TODO: GMaps now have another name, check whether this is a problem somewhere. |
191 | 297 | // Make the map variable available for other functions. |
192 | | - if (!window.GMaps) window.GMaps = new Object; |
193 | | - eval("window.GMaps." + mapName + " = map;"); |
194 | | - |
| 298 | + // if (!window.GMaps) window.GMaps = new Object; |
| 299 | + // eval("window.GMaps." + mapName + " = map;"); |
| 300 | + |
| 301 | + if (!window.GMaps) { |
| 302 | + window.GMaps = new Array(); |
| 303 | + } |
| 304 | + window.GMaps[mapName] = map; |
| 305 | + |
195 | 306 | return map; |
196 | 307 | } |
197 | 308 | |
198 | | -function setupCheckboxShiftClick() { return true; } |
| 309 | +function setupCheckboxShiftClick() { |
| 310 | + return true; |
| 311 | +} |
199 | 312 | |
200 | | -function MoreControl() {}; |
| 313 | +function MoreControl() { |
| 314 | +}; |
201 | 315 | MoreControl.prototype = new GControl(); |
202 | 316 | |
203 | 317 | MoreControl.prototype.initialize = function(map) { |
204 | 318 | this.map = map; |
205 | | - |
| 319 | + |
206 | 320 | var more = document.getElementById(map.name + "-outer-more"); |
207 | 321 | |
208 | 322 | var buttonDiv = document.createElement("div"); |
— | — | @@ -213,7 +327,7 @@ |
214 | 328 | var textDiv = document.createElement("div"); |
215 | 329 | textDiv.id = map.name + "-inner-more"; |
216 | 330 | textDiv.setAttribute('class', 'inner-more'); |
217 | | - textDiv.appendChild(document.createTextNode( msgOverlays )); |
| 331 | + textDiv.appendChild(document.createTextNode(msgOverlays)); |
218 | 332 | |
219 | 333 | buttonDiv.appendChild(textDiv); |
220 | 334 | |
— | — | @@ -222,7 +336,8 @@ |
223 | 337 | more.onmouseout = setGLayerboxClose; |
224 | 338 | |
225 | 339 | // Insert the button just after outer_more div. |
226 | | - more.insertBefore(buttonDiv, document.getElementById(map.name + "-more-box").parentNode); |
| 340 | + more.insertBefore(buttonDiv, document |
| 341 | + .getElementById(map.name + "-more-box").parentNode); |
227 | 342 | |
228 | 343 | // Remove the whole div from its location and reinsert it to the map. |
229 | 344 | map.getContainer().appendChild(more); |
— | — | @@ -234,44 +349,46 @@ |
235 | 350 | return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 35)); |
236 | 351 | }; |
237 | 352 | |
238 | | -function checkGChecked(mapName) { |
239 | | - // Returns true if a checkbox is still checked otherwise false. |
240 | | - var boxes = document.getElementsByName(mapName + "-overlay-box"); |
241 | | - for(var i = 0; i < boxes.length; i++) { |
242 | | - if(boxes[i].checked) return true; |
| 353 | +function checkGChecked(mapName) { |
| 354 | + // Returns true if a checkbox is still checked otherwise false. |
| 355 | + var boxes = document.getElementsByName(mapName + "-overlay-box"); |
| 356 | + for ( var i = 0; i < boxes.length; i++) { |
| 357 | + if (boxes[i].checked) |
| 358 | + return true; |
243 | 359 | } |
244 | 360 | return false; |
245 | 361 | } |
246 | 362 | |
247 | 363 | function showGLayerbox() { |
248 | | - var mapName = this.id.split('-')[0]; |
249 | | - eval("if(window.timer_" + mapName + ") clearTimeout(timer_" + mapName + ");"); |
| 364 | + var mapName = this.id.split('-')[0]; |
| 365 | + eval("if(window.timer_" + mapName + ") clearTimeout(timer_" + mapName |
| 366 | + + ");"); |
250 | 367 | document.getElementById(mapName + "-more-box").style.display = "block"; |
251 | | - var button = document.getElementById(mapName + "-inner-more"); |
| 368 | + var button = document.getElementById(mapName + "-inner-more"); |
252 | 369 | button.style.borderBottomWidth = "4px"; |
253 | 370 | button.style.borderBottomColor = "white"; |
254 | 371 | } |
255 | 372 | |
256 | | - |
257 | 373 | function setGLayerboxClose() { |
258 | 374 | var mapName = this.id.split('-')[0]; |
259 | | - var layerbox = document.getElementById(mapName + "-more-box"); |
260 | | - var button = document.getElementById(mapName + "-inner-more"); |
261 | | - var bottomColor = checkGChecked(mapName) ? "#6495ed" : "#c0c0c0"; |
262 | | - eval("timer_" + mapName + " = window.setTimeout(function() { layerbox.style.display = 'none'; button.style.borderBottomWidth = '1px'; button.style.borderBottomColor = bottomColor; }, 400);"); |
| 375 | + var layerbox = document.getElementById(mapName + "-more-box"); |
| 376 | + var button = document.getElementById(mapName + "-inner-more"); |
| 377 | + var bottomColor = checkGChecked(mapName) ? "#6495ed" : "#c0c0c0"; |
| 378 | + eval("timer_" |
| 379 | + + mapName |
| 380 | + + " = window.setTimeout(function() { layerbox.style.display = 'none'; button.style.borderBottomWidth = '1px'; button.style.borderBottomColor = bottomColor; }, 400);"); |
263 | 381 | } |
264 | 382 | |
265 | 383 | function switchGLayer(map, checked, layer) { |
266 | | - var layerbox = document.getElementById(map.name + "-more-box"); |
267 | | - var button = document.getElementById(map.name + "-inner-more"); |
268 | | - |
269 | | - if(checked) { |
270 | | - map.addOverlay(layer); |
| 384 | + var layerbox = document.getElementById(map.name + "-more-box"); |
| 385 | + var button = document.getElementById(map.name + "-inner-more"); |
| 386 | + |
| 387 | + if (checked) { |
| 388 | + map.addOverlay(layer); |
| 389 | + } else { |
| 390 | + map.removeOverlay(layer); |
271 | 391 | } |
272 | | - else { |
273 | | - map.removeOverlay(layer); |
274 | | - } |
275 | | - |
| 392 | + |
276 | 393 | } |
277 | 394 | |
278 | 395 | function initiateGOverlay(elementId, mapName, urlNr) { |