Index: trunk/extensions/Maps/Maps.i18n.php |
— | — | @@ -16,7 +16,9 @@ |
17 | 17 | $messages['en'] = array( |
18 | 18 | // General |
19 | 19 | 'maps-desc' => "Enables embedding of dynamic maps into wiki pages, geocoding of addresses and other geographical operations. ([http://mapping.referata.com/wiki/Examples demos])", |
| 20 | + |
20 | 21 | 'right-geocode' => 'Geocode', |
| 22 | + |
21 | 23 | 'maps_map' => 'Map', |
22 | 24 | 'maps-loading-map' => 'Loading map...', |
23 | 25 | 'maps-load-failed' => 'Could not load the map!', |
— | — | @@ -51,7 +53,7 @@ |
52 | 54 | // Mapsdoc parser hook |
53 | 55 | 'maps-mapsdoc-par-service' => 'The mapping service to display parameter documentation for.', |
54 | 56 | 'maps-mapsdoc-par-language' => 'The language in which to display the documentation. If no such translation is available, English will be used instead.', |
55 | | - |
| 57 | + |
56 | 58 | // Coordinates parser hook |
57 | 59 | 'maps-coordinates-par-location' => 'The coordinates you want to format.', |
58 | 60 | 'maps-coordinates-par-format' => 'The target format for the coordinates.', |
— | — | @@ -124,7 +126,8 @@ |
125 | 127 | |
126 | 128 | 'validation-error-invalid-goverlay' => 'Parameter $1 must be a valid overlay.', |
127 | 129 | 'validation-error-invalid-goverlays' => 'Parameter $1 must be one or more valid overlays.', |
128 | | - 'validation-error-invalid-line-param' => 'Invalid "lines" parameter specified.', |
| 130 | + 'validation-error-invalid-line-param' => 'Invalid "lines" parameter specified.', |
| 131 | + 'validation-error-invalid-polyline-param' => 'Invalid "polylines" parameter specified.', |
129 | 132 | |
130 | 133 | // Coordinate handling |
131 | 134 | 'maps-abb-north' => 'N', |
— | — | @@ -250,9 +253,6 @@ |
251 | 254 | 'maps-googlemaps3-par-tilt' => '{{maps-par|googlemaps3|tilt}}', |
252 | 255 | 'maps-googlemaps3-par-kmlrezoom' => '{{maps-par|googlemaps3|kmlrezoom}}', |
253 | 256 | 'maps-googlemaps3-par-poi' => '{{maps-par|googlemaps3|poi}}', |
254 | | - 'maps-copycoords-prompt' => 'text displayed in javascript prompt to indicate first press ctrl+c to copy text, and press enter to close prompt', |
255 | | - 'maps-clustering-unsupportedservice' => 'text describing that the chosen maps service doesn\'t support clustering of markers', |
256 | | - 'validation-error-invalid-line-param' => 'validation text indicating that there is something wrong with the "lines" parameter' |
257 | 257 | ); |
258 | 258 | |
259 | 259 | /** Afrikaans (Afrikaans) |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -81,6 +81,7 @@ |
82 | 82 | $wgAutoloadClasses['MapsLayers'] = $incDir . 'Maps_Layers.php'; |
83 | 83 | $wgAutoloadClasses['MapsLocation'] = $incDir . 'Maps_Location.php'; |
84 | 84 | $wgAutoloadClasses['MapsLine'] = $incDir . 'Maps_Line.php'; |
| 85 | +$wgAutoloadClasses['MapsPolygon'] = $incDir . 'Maps_Polygon.php'; |
85 | 86 | $wgAutoloadClasses['iMappingService'] = $incDir . 'iMappingService.php'; |
86 | 87 | $wgAutoloadClasses['MapsMappingServices'] = $incDir . 'Maps_MappingServices.php'; |
87 | 88 | $wgAutoloadClasses['MapsMappingService'] = $incDir . 'Maps_MappingService.php'; |
— | — | @@ -95,6 +96,7 @@ |
96 | 97 | $wgAutoloadClasses['CriterionMapDimension'] = $criDir . 'CriterionMapDimension.php'; |
97 | 98 | $wgAutoloadClasses['CriterionMapLayer'] = $criDir . 'CriterionMapLayer.php'; |
98 | 99 | $wgAutoloadClasses['CriterionLine'] = $criDir . 'CriterionLine.php'; |
| 100 | +$wgAutoloadClasses['CriterionPolygon'] = $criDir . 'CriterionPolygon.php'; |
99 | 101 | unset( $criDir ); |
100 | 102 | |
101 | 103 | // Autoload the "includes/features/" classes. |
— | — | @@ -126,6 +128,7 @@ |
127 | 129 | $wgAutoloadClasses['MapsParamService'] = $manDir . 'Maps_ParamService.php'; |
128 | 130 | $wgAutoloadClasses['MapsParamZoom'] = $manDir . 'Maps_ParamZoom.php'; |
129 | 131 | $wgAutoloadClasses['MapsParamLine'] = $manDir . 'Maps_ParamLine.php'; |
| 132 | +$wgAutoloadClasses['MapsParamPolygon'] = $manDir . 'Maps_ParamPolygon.php'; |
130 | 133 | unset( $manDir ); |
131 | 134 | |
132 | 135 | // Autoload the "includes/parserHooks/" classes. |
Index: trunk/extensions/Maps/RELEASE-NOTES |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | * 'display_line' new parser function which has the parameter lines where one can specify coordinates/locations where a line should be drawn between, lines color. Currently supported with googlemaps and openlayers. |
21 | 21 | * 'display_line' new parameter copycoords, when set to "on" will give right clicks on map a prompt of longitude and latitude coordinates |
22 | 22 | * 'display_line' new parameter markercluster, when set to "on" will cluster closely adjacent markers together. |
| 23 | +* 'display_line' new parameter polygons, has same syntax as lines parameter and can draw polygons on map |
23 | 24 | |
24 | 25 | === Maps 1.0.5 === |
25 | 26 | (2011-11-30) |
Index: trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js |
— | — | @@ -27,6 +27,11 @@ |
28 | 28 | */ |
29 | 29 | this.lines = []; |
30 | 30 | |
| 31 | + /** |
| 32 | + * All polygons currently on the map, |
| 33 | + */ |
| 34 | + this.polygons = []; |
| 35 | + |
31 | 36 | /** |
32 | 37 | * Creates a new marker with the provided data, |
33 | 38 | * adds it to the map, and returns it. |
— | — | @@ -188,8 +193,59 @@ |
189 | 194 | this.lines[i].setMap( null ); |
190 | 195 | } |
191 | 196 | this.lines = []; |
192 | | - } |
| 197 | + }; |
193 | 198 | |
| 199 | + this.addPolygon = function(properties){ |
| 200 | + var paths = new google.maps.MVCArray(); |
| 201 | + for(var x = 0; x < properties.pos.length; x++){ |
| 202 | + paths.push(new google.maps.LatLng( properties.pos[x].lat , properties.pos[x].lon )); |
| 203 | + } |
| 204 | + |
| 205 | + var polygon = new google.maps.Polygon({ |
| 206 | + map:this.map, |
| 207 | + path:paths, |
| 208 | + strokeColor:properties.strokeColor, |
| 209 | + strokeOpacity:properties.strokeOpacity, |
| 210 | + strokeWeight:properties.strokeWeight, |
| 211 | + fillColor:properties.fillColor, |
| 212 | + fillOpacity: properties.fillOpacity |
| 213 | + }); |
| 214 | + this.polygons.push(polygon); |
| 215 | + |
| 216 | + google.maps.event.addListener(polygon,"click", function(event){ |
| 217 | + if (this.openWindow != undefined) { |
| 218 | + this.openWindow.close(); |
| 219 | + } |
| 220 | + this.openWindow = new google.maps.InfoWindow(); |
| 221 | + this.openWindow.content = properties.text; |
| 222 | + this.openWindow.position = event.latLng; |
| 223 | + this.openWindow.closeclick = function() { |
| 224 | + polygon.openWindow = undefined; |
| 225 | + }; |
| 226 | + this.openWindow.open(_this.map); |
| 227 | + }); |
| 228 | + }; |
| 229 | + |
| 230 | + this.removePolygon = function(polygon){ |
| 231 | + polygon.setMap( null ); |
| 232 | + |
| 233 | + for ( var i = this.polygon.length - 1; i >= 0; i-- ) { |
| 234 | + if ( this.polygon[i] === polygon ) { |
| 235 | + delete this.polygon[i]; |
| 236 | + break; |
| 237 | + } |
| 238 | + } |
| 239 | + |
| 240 | + delete polygon; |
| 241 | + }; |
| 242 | + |
| 243 | + this.removePolygons = function(){ |
| 244 | + for ( var i = this.polygon.length - 1; i >= 0; i-- ) { |
| 245 | + this.polygon[i].setMap( null ); |
| 246 | + } |
| 247 | + this.polygon = []; |
| 248 | + }; |
| 249 | + |
194 | 250 | this.setup = function() { |
195 | 251 | var showEarth = $.inArray( 'earth', options.types ) !== -1; |
196 | 252 | |
— | — | @@ -380,6 +436,15 @@ |
381 | 437 | } |
382 | 438 | |
383 | 439 | /** |
| 440 | + * used in display_line to draw polygons |
| 441 | + */ |
| 442 | + if(options.polygons){ |
| 443 | + for ( var i = 0; i < options.polygons.length; i++ ) { |
| 444 | + this.addPolygon(options.polygons[i]); |
| 445 | + } |
| 446 | + } |
| 447 | + |
| 448 | + /** |
384 | 449 | * used in display_line functionality |
385 | 450 | * allows the copy to clipboard of coordinates |
386 | 451 | */ |
Index: trunk/extensions/Maps/includes/services/OpenLayers/jquery.openlayers.js |
— | — | @@ -125,6 +125,30 @@ |
126 | 126 | var lineFeature = new OpenLayers.Feature.Vector(line, {text:properties.text}, style); |
127 | 127 | this.lineLayer.addFeatures([lineFeature]); |
128 | 128 | } |
| 129 | + |
| 130 | + this.addPolygon = function(properties){ |
| 131 | + var pos = new Array(); |
| 132 | + for(var x = 0; x < properties.pos.length; x++){ |
| 133 | + var point = new OpenLayers.Geometry.Point(properties.pos[x].lon,properties.pos[x].lat); |
| 134 | + point.transform( |
| 135 | + new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984 |
| 136 | + map.getProjectionObject() // to Spherical Mercator Projection |
| 137 | + ); |
| 138 | + pos.push(point); |
| 139 | + } |
| 140 | + |
| 141 | + var style = { |
| 142 | + 'strokeColor':properties.strokeColor, |
| 143 | + 'strokeWidth': properties.strokeWeight, |
| 144 | + 'strokeOpacity': properties.strokeOpacity, |
| 145 | + 'fillColor': properties.fillColor, |
| 146 | + 'fillOpacity': properties.fillOpacity |
| 147 | + } |
| 148 | + |
| 149 | + var polygon = new OpenLayers.Geometry.LinearRing(pos); |
| 150 | + var polygonFeature = new OpenLayers.Feature.Vector(polygon, {text:properties.text}, style); |
| 151 | + this.polygonLayer.addFeatures([polygonFeature]); |
| 152 | + } |
129 | 153 | |
130 | 154 | /** |
131 | 155 | * Gets a valid control name (with excat lower and upper case letters), |
— | — | @@ -232,6 +256,47 @@ |
233 | 257 | } |
234 | 258 | } |
235 | 259 | |
| 260 | + if(options.polygons && options.polygons.length > 0){ |
| 261 | + this.polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer"); |
| 262 | + this.polygonLayer.events.on({ |
| 263 | + 'featureselected':function(feature){ |
| 264 | + if(feature.feature.attributes.text != undefined && feature.feature.attributes.text != ''){ |
| 265 | + var mousePos = map.getControlsByClass("OpenLayers.Control.MousePosition")[0].lastXy |
| 266 | + var lonlat = map.getLonLatFromPixel(mousePos); |
| 267 | + var popup = new OpenLayers.Popup(null,lonlat, null, feature.feature.attributes.text, true,function(){ |
| 268 | + map.getControlsByClass('OpenLayers.Control.SelectFeature')[0].unselectAll(); |
| 269 | + map.removePopup(this); |
| 270 | + }) |
| 271 | + this.map.addPopup( popup ); |
| 272 | + } |
| 273 | + }, |
| 274 | + 'featureunselected':function(feature){ |
| 275 | + //do nothing |
| 276 | + } |
| 277 | + }); |
| 278 | + |
| 279 | + var controls = { |
| 280 | + select: new OpenLayers.Control.SelectFeature(this.polygonLayer,{ |
| 281 | + clickout: true, toggle: false, |
| 282 | + multiple: true, hover: false |
| 283 | + }) |
| 284 | + }; |
| 285 | + |
| 286 | + for(key in controls){ |
| 287 | + var control = controls[key]; |
| 288 | + map.addControl(control); |
| 289 | + control.activate(); |
| 290 | + } |
| 291 | + |
| 292 | + map.addLayer(this.polygonLayer); |
| 293 | + map.raiseLayer(this.polygonLayer,-1); |
| 294 | + map.resetLayersZIndex(); |
| 295 | + |
| 296 | + for ( var i = 0; i < options.polygons.length; i++ ) { |
| 297 | + this.addPolygon(options.polygons[i]); |
| 298 | + } |
| 299 | + } |
| 300 | + |
236 | 301 | if ( options.centre === false ) { |
237 | 302 | if ( options.locations.length == 1 ) { |
238 | 303 | centre = new OpenLayers.LonLat( options.locations[0].lon, options.locations[0].lat ); |
Index: trunk/extensions/Maps/includes/parserHooks/Maps_DisplayLine.php |
— | — | @@ -68,6 +68,11 @@ |
69 | 69 | $params['lines']->addCriteria(new CriterionLine()); |
70 | 70 | $params['lines']->addManipulations( new MapsParamLine() ); |
71 | 71 | |
| 72 | + $params['polygons'] = new ListParameter( 'polygons', ';' ); |
| 73 | + $params['polygons']->setDefault(array()); |
| 74 | + $params['polygons']->addCriteria(new CriterionPolygon()); |
| 75 | + $params['polygons']->addManipulations( new MapsParamPolygon() ); |
| 76 | + |
72 | 77 | $params['copycoords'] = new Parameter( |
73 | 78 | 'copycoords', |
74 | 79 | Parameter::TYPE_BOOLEAN |
— | — | @@ -95,6 +100,6 @@ |
96 | 101 | * @return array |
97 | 102 | */ |
98 | 103 | protected function getDefaultParameters( $type ) { |
99 | | - return array( 'coordinates','lines' ); |
| 104 | + return array( 'coordinates','lines','polygons' ); |
100 | 105 | } |
101 | 106 | } |
\ No newline at end of file |