r54689 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54688‎ | r54689 | r54690 >
Date:23:36, 9 August 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.3.
Modified paths:
  • /trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Settings.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php
@@ -55,8 +55,9 @@
5656 $enableEarth = MapsGoogleMapsUtils::getEarthValue($this->earth);
5757
5858 $this->type = MapsGoogleMapsUtils::getGMapType($this->type, true);
59 - $control = MapsGoogleMapsUtils::getGControlType($this->controls);
6059
 60+ $this->controls = MapsGoogleMapsUtils::createControlsString($this->controls);
 61+
6162 $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom);
6263
6364 $markerItems = array();
@@ -82,7 +83,7 @@
8384 <div id="$this->mapName" class="$this->class" style="$this->style" ></div>
8485 <script type="$wgJsMimeType"> /*<![CDATA[*/
8586 addLoadEvent(
86 - initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], new $control(), $this->autozoom, [$markersString])
 87+ initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
8788 );
8889 /*]]>*/ </script>
8990
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php
@@ -85,18 +85,15 @@
8686 }
8787
8888 /**
89 - * Returns the Google Map Control type (defined in MapsGoogleMaps::$controlClasses)
90 - * for the provided a general map control type. When no match is found, the provided
91 - * control name will be used.
 89+ * Build up a csv string with the controls, to be outputted as a JS array
9290 *
9391 * @param array $controls
94 - * @return string
 92+ * @return csv string
9593 */
96 - public static function getGControlType(array $controls) {
97 - global $egMapsGMapControl;
98 - $control = count($controls) > 0 ? $controls[0] : $egMapsGMapControl;
99 - return array_key_exists($control, self::$controlClasses) ? self::$controlClasses[$control] : $control;
100 - }
 94+ public static function createControlsString(array $controls) {
 95+ global $egMapsGMapControls;
 96+ return MapsMapper::createJSItemsString($controls, $egMapsGMapControls);
 97+ }
10198
10299 /**
103100 * Retuns an array holding the default parameters and their values.
Index: trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js
@@ -42,13 +42,13 @@
4343 /**
4444 * Returns GMap2 object with the provided properties and markers.
4545 */
46 -function initializeGoogleMap(mapName, width, height, lat, lon, zoom, type, types, control, scrollWheelZoom, markers) {
 46+function initializeGoogleMap(mapName, width, height, lat, lon, zoom, type, types, controls, scrollWheelZoom, markers) {
4747 var map;
4848
4949 var centre = (lat != null && lon != null) ? new GLatLng(lat, lon) : null;
5050
5151 if (GBrowserIsCompatible()) {
52 - map = createGoogleMap(document.getElementById(mapName), new GSize(width, height), centre, zoom, type, types, control, scrollWheelZoom, markers);
 52+ map = createGoogleMap(document.getElementById(mapName), new GSize(width, height), centre, zoom, type, types, controls, scrollWheelZoom, markers);
5353 }
5454
5555 return map;
@@ -57,9 +57,10 @@
5858 /**
5959 * Returns GMap2 object with the provided properties.
6060 */
61 -function createGoogleMap(mapElement, size, centre, zoom, type, types, control, scrollWheelZoom, markers) {
 61+function createGoogleMap(mapElement, size, centre, zoom, type, types, controls, scrollWheelZoom, markers) {
6262 var typesContainType = false;
6363
 64+ // TODO: Change labels of the moon/mars map types?
6465 for (var i = 0; i < types.length; i++) {
6566 if (types[i] == type) typesContainType = true;
6667 }
@@ -67,13 +68,47 @@
6869 if (! typesContainType) {
6970 types.push(type);
7071 }
 72+
 73+ var map = new GMap2(mapElement, {size: size, mapTypes: types});
7174
72 - // TODO: Change labels of the moon/mars map types?
 75+ map.setMapType(type);
7376
74 - var map = new GMap2(mapElement, {size: size, mapTypes: types});
 77+ // List of GControls: http://code.google.com/apis/maps/documentation/reference.html#GControl
 78+ for (i in controls){
 79+ switch (controls[i]) {
 80+ case 'large' :
 81+ map.addControl(new GLargeMapControl3D());
 82+ break;
 83+ case 'small' :
 84+ map.addControl(new GSmallZoomControl3D());
 85+ break;
 86+ case 'large-original' :
 87+ map.addControl(new GLargeMapControl());
 88+ break;
 89+ case 'small-original' :
 90+ map.addControl(new GSmallMapControl());
 91+ break;
 92+ case 'zoom' :
 93+ map.addControl(new GSmallZoomControl());
 94+ break;
 95+ case 'type' :
 96+ map.addControl(new GMapTypeControl());
 97+ break;
 98+ case 'type-menu' :
 99+ map.addControl(new GMenuMapTypeControl());
 100+ break;
 101+ case 'overview' : case 'overview-map' :
 102+ map.addControl(new GOverviewMapControl());
 103+ break;
 104+ case 'scale' :
 105+ map.addControl(new GScaleControl());
 106+ break;
 107+ case 'nav-label' : case 'nav' :
 108+ map.addControl(new GNavLabelControl());
 109+ break;
 110+ }
 111+ }
75112
76 - map.setMapType(type);
77 -
78113 var bounds = ((zoom == null || centre == null) && markers.length > 1) ? new GLatLngBounds() : null;
79114
80115 for (i in markers) {
@@ -89,9 +124,6 @@
90125 if (centre != null) map.setCenter(centre);
91126 if (zoom != null) map.setZoom(zoom);
92127
93 - map.addControl(new GMapTypeControl());
94 -
95 - if (typeof(control) != 'undefined') map.addControl(control);
96128 if (scrollWheelZoom) map.enableScrollWheelZoom();
97129
98130 map.enableContinuousZoom();
Index: trunk/extensions/Maps/Maps_Settings.php
@@ -99,11 +99,15 @@
100100 $egMapsEnableEarth = false;
101101
102102 # String. The default control for Google Maps. This value will only be used when the user does not provide one.
103 -# Available short values: large, small. Other values: http://code.google.com/apis/maps/documentation/controls.html#Controls_overview
104 -$egMapsGMapControl = 'large';
 103+# Available short values: large, small. Other values:
 104+$egMapsGMapControl = '';
105105
 106+# Array of String. The default controls for Google Maps. This value will only be used when the user does not provide one.
 107+# Available values: large, small, large-original, small-original, zoom, type, type-menu, overview-map, scale, nav-label
 108+$egMapsGMapControls = array('large', 'scale', 'type');
106109
107110
 111+
108112 # Yahoo maps
109113
110114 # String. The Yahoo maps map name prefix. It can not be identical to the one of another mapping service.

Status & tagging log