r83508 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83507‎ | r83508 | r83509 >
Date:04:27, 8 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
kml support fixes
Modified paths:
  • /branches/Maps0.8/Maps_Settings.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMaps.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps/jquery.googlemap2.js (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps3/Maps_GoogleMaps3.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps3/jquery.googlemap.js (modified) (history)

Diff [purge]

Index: branches/Maps0.8/Maps_Settings.php
@@ -199,6 +199,7 @@
200200
201201 $egMapsGMaps3AutoInfoWindows = false;
202202
 203+ $egMapsGMaps3Layers = array();
203204
204205
205206
@@ -254,9 +255,9 @@
255256 'wikipedia',
256257 'webcams'
257258 );
 259+
258260
259261
260 -
261262 # Yahoo! Maps
262263
263264 # Your Yahoo! Maps API key. Required for displaying Yahoo! Maps.
Index: branches/Maps0.8/includes/services/GoogleMaps3/jquery.googlemap.js
@@ -62,6 +62,20 @@
6363 markers.push( marker );
6464 }
6565
 66+ // Code to add KML files.
 67+ for ( i = options.kml.length - 1; i >= 0; i-- ) {
 68+ var kmlLayer = new google.maps.KmlLayer( options.kml[i], { map: map } );
 69+ }
 70+
 71+ var layerMapping = {
 72+ 'traffic': 'new google.maps.TrafficLayer()',
 73+ 'bicycling': 'new google.maps.BicyclingLayer()'
 74+ };
 75+
 76+ for ( i = options.layers.length - 1; i >= 0; i-- ) {
 77+ var layer = eval( layerMapping[options.layers[i]] );
 78+ }
 79+
6680 var bounds;
6781
6882 if ( ( options.centre === false || options.zoom === false ) && options.locations.length > 1 ) {
Index: branches/Maps0.8/includes/services/GoogleMaps3/Maps_GoogleMaps3.php
@@ -29,6 +29,18 @@
3030 'physical' => 'TERRAIN'
3131 );
3232
 33+ /**
 34+ * List of supported map layers.
 35+ *
 36+ * @since 0.8
 37+ *
 38+ * @var array
 39+ */
 40+ protected static $mapLayers = array(
 41+ 'traffic',
 42+ 'bicyling'
 43+ );
 44+
3345 public static $tyepControlStyles = array(
3446 'default' => 'DEFAULT',
3547 'horizontal' => 'HORIZONTAL_BAR',
@@ -68,7 +80,7 @@
6981 * @since 0.7
7082 */
7183 public function addParameterInfo( array &$params ) {
72 - global $egMapsGMaps3Type, $egMapsGMaps3Types, $egMapsGMaps3Controls;
 84+ global $egMapsGMaps3Type, $egMapsGMaps3Types, $egMapsGMaps3Controls, $egMapsGMaps3Layers;
7385 global $egMapsGMaps3DefTypeStyle, $egMapsGMaps3DefZoomStyle, $egMapsGMaps3AutoInfoWindows;
7486
7587 $params['zoom']->addCriteria( new CriterionInRange( 0, 20 ) );
@@ -84,6 +96,10 @@
8597 $params['types']->addCriteria( new CriterionInArray( self::getTypeNames() ) );
8698 $params['types']->addManipulations( new MapsParamGMap3Type() );
8799
 100+ $params['layers'] = new ListParameter( 'layers' );
 101+ $params['layers']->setDefault( $egMapsGMaps3Layers );
 102+ $params['layers']->addCriteria( new CriterionInArray( self::getLayerNames() ) );
 103+
88104 $params['controls'] = new ListParameter( 'controls' );
89105 $params['controls']->setDefault( $egMapsGMaps3Controls );
90106 $params['controls']->addCriteria( new CriterionInArray( self::$controlNames ) );
@@ -101,6 +117,10 @@
102118
103119 $params['autoinfowindows'] = new Parameter( 'autoinfowindows', Parameter::TYPE_BOOLEAN );
104120 $params['autoinfowindows']->setDefault( $egMapsGMaps3AutoInfoWindows );
 121+
 122+ $params['kml'] = new ListParameter( 'kml' );
 123+ $params['kml']->setDefault( array() );
 124+ //$params['kml']->addManipulations( new MapsParamFile() );
105125 }
106126
107127 /**
@@ -138,6 +158,17 @@
139159 }
140160
141161 /**
 162+ * Returns the names of all supported map layers.
 163+ *
 164+ * @since 0.8
 165+ *
 166+ * @return array
 167+ */
 168+ public static function getLayerNames() {
 169+ return array_keys( self::$mapLayers );
 170+ }
 171+
 172+ /**
142173 * @see MapsMappingService::getDependencies
143174 *
144175 * @return array
Index: branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMaps.php
@@ -85,7 +85,7 @@
8686
8787 $params['kml'] = new ListParameter( 'kml' );
8888 $params['kml']->setDefault( array() );
89 - $params['kml']->addManipulations( new MapsParamFile() );
 89+ //$params['kml']->addManipulations( new MapsParamFile() );
9090
9191 $params['overlays'] = new ListParameter( 'overlays' );
9292 $params['overlays']->setDefault( $egMapsGMapOverlays );
Index: branches/Maps0.8/includes/services/GoogleMaps/jquery.googlemap2.js
@@ -86,7 +86,7 @@
8787 if ( !options.locations ) {
8888 options.locations = [];
8989 }
90 -
 90+
9191 var bounds = ( ( options.zoom === false || options.centre === false ) && options.locations.length > 1 ) ? new GLatLngBounds() : null;
9292
9393 for ( i = options.locations.length - 1; i >= 0; i-- ) {
@@ -115,13 +115,9 @@
116116 map.enableContinuousZoom();
117117
118118 // Code to add KML files.
119 - /*
120 - var kmlOverlays = [];
121 - for ( i = args.kml.length - 1; i >= 0; i-- ) {
122 - kmlOverlays[i] = new GGeoXml( args.kml[i] );
123 - map.addOverlay( kmlOverlays[i] );
 119+ for ( i = options.kml.length - 1; i >= 0; i-- ) {
 120+ map.addOverlay( new GGeoXml( options.kml[i] ) );
124121 }
125 - */
126122
127123 function ensureTypeIsSelectable( type, types ) {
128124 var typesContainType = false;

Status & tagging log