Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -55,8 +55,9 @@ |
56 | 56 | $enableEarth = MapsGoogleMapsUtils::getEarthValue($this->earth); |
57 | 57 | |
58 | 58 | $this->type = MapsGoogleMapsUtils::getGMapType($this->type, true); |
59 | | - $control = MapsGoogleMapsUtils::getGControlType($this->controls); |
60 | 59 | |
| 60 | + $this->controls = MapsGoogleMapsUtils::createControlsString($this->controls); |
| 61 | + |
61 | 62 | $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom); |
62 | 63 | |
63 | 64 | $markerItems = array(); |
— | — | @@ -82,7 +83,7 @@ |
83 | 84 | <div id="$this->mapName" class="$this->class" style="$this->style" ></div> |
84 | 85 | <script type="$wgJsMimeType"> /*<![CDATA[*/ |
85 | 86 | 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]) |
87 | 88 | ); |
88 | 89 | /*]]>*/ </script> |
89 | 90 | |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php |
— | — | @@ -85,18 +85,15 @@ |
86 | 86 | }
|
87 | 87 |
|
88 | 88 | /**
|
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
|
92 | 90 | *
|
93 | 91 | * @param array $controls
|
94 | | - * @return string
|
| 92 | + * @return csv string
|
95 | 93 | */
|
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 | + }
|
101 | 98 |
|
102 | 99 | /**
|
103 | 100 | * Retuns an array holding the default parameters and their values.
|
Index: trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js |
— | — | @@ -42,13 +42,13 @@ |
43 | 43 | /** |
44 | 44 | * Returns GMap2 object with the provided properties and markers. |
45 | 45 | */ |
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) { |
47 | 47 | var map; |
48 | 48 | |
49 | 49 | var centre = (lat != null && lon != null) ? new GLatLng(lat, lon) : null; |
50 | 50 | |
51 | 51 | 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); |
53 | 53 | } |
54 | 54 | |
55 | 55 | return map; |
— | — | @@ -57,9 +57,10 @@ |
58 | 58 | /** |
59 | 59 | * Returns GMap2 object with the provided properties. |
60 | 60 | */ |
61 | | -function createGoogleMap(mapElement, size, centre, zoom, type, types, control, scrollWheelZoom, markers) { |
| 61 | +function createGoogleMap(mapElement, size, centre, zoom, type, types, controls, scrollWheelZoom, markers) { |
62 | 62 | var typesContainType = false; |
63 | 63 | |
| 64 | + // TODO: Change labels of the moon/mars map types? |
64 | 65 | for (var i = 0; i < types.length; i++) { |
65 | 66 | if (types[i] == type) typesContainType = true; |
66 | 67 | } |
— | — | @@ -67,13 +68,47 @@ |
68 | 69 | if (! typesContainType) { |
69 | 70 | types.push(type); |
70 | 71 | } |
| 72 | + |
| 73 | + var map = new GMap2(mapElement, {size: size, mapTypes: types}); |
71 | 74 | |
72 | | - // TODO: Change labels of the moon/mars map types? |
| 75 | + map.setMapType(type); |
73 | 76 | |
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 | + } |
75 | 112 | |
76 | | - map.setMapType(type); |
77 | | - |
78 | 113 | var bounds = ((zoom == null || centre == null) && markers.length > 1) ? new GLatLngBounds() : null; |
79 | 114 | |
80 | 115 | for (i in markers) { |
— | — | @@ -89,9 +124,6 @@ |
90 | 125 | if (centre != null) map.setCenter(centre); |
91 | 126 | if (zoom != null) map.setZoom(zoom); |
92 | 127 | |
93 | | - map.addControl(new GMapTypeControl()); |
94 | | - |
95 | | - if (typeof(control) != 'undefined') map.addControl(control); |
96 | 128 | if (scrollWheelZoom) map.enableScrollWheelZoom(); |
97 | 129 | |
98 | 130 | map.enableContinuousZoom(); |
Index: trunk/extensions/Maps/Maps_Settings.php |
— | — | @@ -99,11 +99,15 @@ |
100 | 100 | $egMapsEnableEarth = false; |
101 | 101 | |
102 | 102 | # 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 = ''; |
105 | 105 | |
| 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'); |
106 | 109 | |
107 | 110 | |
| 111 | + |
108 | 112 | # Yahoo maps |
109 | 113 | |
110 | 114 | # String. The Yahoo maps map name prefix. It can not be identical to the one of another mapping service. |