Index: trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_ParamGMap3Types.php |
— | — | @@ -0,0 +1,37 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parameter manipulation ensuring that the map types list contains the map type. |
| 6 | + * |
| 7 | + * @since 1.0.1 |
| 8 | + * |
| 9 | + * @file Maps_ParamGMap3Types.php |
| 10 | + * @ingroup Maps |
| 11 | + * @ingroup ParameterManipulations |
| 12 | + * @ingroup MapsGoogleMaps |
| 13 | + * |
| 14 | + * @licence GNU GPL v3 |
| 15 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 16 | + */ |
| 17 | +class MapsParamGMap3Types extends ListParameterManipulation { |
| 18 | + |
| 19 | + /** |
| 20 | + * @see ParameterManipulation::manipulate |
| 21 | + * |
| 22 | + * @since 1.0.1 |
| 23 | + */ |
| 24 | + public function manipulate( Parameter &$parameter, array &$parameters ) { |
| 25 | + if ( !in_array( $parameters['type']->getValue(), $parameter->getValue() ) ) { |
| 26 | + if ( $parameters['type']->wasSetToDefault() ) { |
| 27 | + if ( count( $parameter->getValue() ) > 0 ) { |
| 28 | + $types = $parameter->getValue(); |
| 29 | + $parameters['type']->setValue( $types[0] ); |
| 30 | + } |
| 31 | + } |
| 32 | + else { |
| 33 | + array_unshift( $parameter->getValue(), $parameters['type']->getValue() ); |
| 34 | + } |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_ParamGMap3Types.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 39 | + native |
Index: trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js |
— | — | @@ -83,6 +83,44 @@ |
84 | 84 | this.markers = []; |
85 | 85 | }; |
86 | 86 | |
| 87 | + var showEarth = $.inArray( 'earth', options.types ); |
| 88 | + |
| 89 | + // If there are any non-Google KML/KMZ layers, load the geoxml library and use it to add these layers. |
| 90 | + if ( showEarth ) { |
| 91 | + // Yay, IE seriously fails. Compat code for IE < 9. |
| 92 | + if (!Array.prototype.filter) |
| 93 | + { |
| 94 | + Array.prototype.filter = function(fun /*, thisp */) |
| 95 | + { |
| 96 | + "use strict"; |
| 97 | + |
| 98 | + if (this === void 0 || this === null) |
| 99 | + throw new TypeError(); |
| 100 | + |
| 101 | + var t = Object(this); |
| 102 | + var len = t.length >>> 0; |
| 103 | + if (typeof fun !== "function") |
| 104 | + throw new TypeError(); |
| 105 | + |
| 106 | + var res = []; |
| 107 | + var thisp = arguments[1]; |
| 108 | + for (var i = 0; i < len; i++) |
| 109 | + { |
| 110 | + if (i in t) |
| 111 | + { |
| 112 | + var val = t[i]; // in case fun mutates this |
| 113 | + if (fun.call(thisp, val, i, t)) |
| 114 | + res.push(val); |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + return res; |
| 119 | + }; |
| 120 | + } |
| 121 | + |
| 122 | + options.types.filter( function( element, index, array ) { return element != 'earth'; } ); |
| 123 | + } |
| 124 | + |
87 | 125 | var mapOptions = { |
88 | 126 | disableDefaultUI: true, |
89 | 127 | mapTypeId: options.type == 'earth' ? google.maps.MapTypeId.SATELLITE : eval( 'google.maps.MapTypeId.' + options.type ) |
— | — | @@ -96,9 +134,16 @@ |
97 | 135 | mapOptions.scaleControl = $.inArray( 'scale', options.controls ) != -1; |
98 | 136 | mapOptions.streetViewControl = $.inArray( 'streetview', options.controls ) != -1; |
99 | 137 | |
| 138 | + for ( i in options.types ) { |
| 139 | + options.types[i] = eval( 'google.maps.MapTypeId.' + options.types[i] ); |
| 140 | + } |
| 141 | + |
100 | 142 | // Map control styles |
101 | | - mapOptions.zoomControlOptions = { style: eval( 'google.maps.ZoomControlStyle.' + options.zoomstyle ) } |
102 | | - mapOptions.mapTypeControlOptions = { style: eval( 'google.maps.MapTypeControlStyle.' + options.typestyle ) } |
| 143 | + mapOptions.zoomControlOptions = { style: eval( 'google.maps.ZoomControlStyle.' + options.zoomstyle ) }; |
| 144 | + mapOptions.mapTypeControlOptions = { |
| 145 | + style: eval( 'google.maps.MapTypeControlStyle.' + options.typestyle ), |
| 146 | + mapTypeIds: options.types |
| 147 | + }; |
103 | 148 | |
104 | 149 | var map = new google.maps.Map( this.get( 0 ), mapOptions ); |
105 | 150 | this.map = map; |
— | — | @@ -129,48 +174,12 @@ |
130 | 175 | } ); |
131 | 176 | } |
132 | 177 | |
133 | | - // If there are any non-Google KML/KMZ layers, load the geoxml library and use it to add these layers. |
134 | | - if ( $.inArray( 'earth', options.types ) ) { |
| 178 | + if ( showEarth ) { |
135 | 179 | mw.loader.using( 'ext.maps.gm3.earth', function() { |
136 | 180 | var ge = new GoogleEarth( map ); |
137 | | - } ); |
138 | | - |
139 | | - // Yay, IE seriously fails. Compat code for IE < 9. |
140 | | - if (!Array.prototype.filter) |
141 | | - { |
142 | | - Array.prototype.filter = function(fun /*, thisp */) |
143 | | - { |
144 | | - "use strict"; |
145 | | - |
146 | | - if (this === void 0 || this === null) |
147 | | - throw new TypeError(); |
148 | | - |
149 | | - var t = Object(this); |
150 | | - var len = t.length >>> 0; |
151 | | - if (typeof fun !== "function") |
152 | | - throw new TypeError(); |
153 | | - |
154 | | - var res = []; |
155 | | - var thisp = arguments[1]; |
156 | | - for (var i = 0; i < len; i++) |
157 | | - { |
158 | | - if (i in t) |
159 | | - { |
160 | | - var val = t[i]; // in case fun mutates this |
161 | | - if (fun.call(thisp, val, i, t)) |
162 | | - res.push(val); |
163 | | - } |
164 | | - } |
165 | | - |
166 | | - return res; |
167 | | - }; |
168 | | - } |
169 | | - |
170 | | - options.types.filter( function( element, index, array ) { return element != 'earth'; } ); |
| 181 | + } ); |
171 | 182 | } |
172 | 183 | |
173 | | - // TODO: map types |
174 | | - |
175 | 184 | for ( i = options.fusiontables.length - 1; i >= 0; i-- ) { |
176 | 185 | var ftLayer = new google.maps.FusionTablesLayer( options.fusiontables[i], { map: map } ); |
177 | 186 | } |
Index: trunk/extensions/Maps/includes/services/GoogleMaps3/GoogleMaps3.php |
— | — | @@ -13,7 +13,8 @@ |
14 | 14 | * @file GoogleMaps3.php |
15 | 15 | * @ingroup MapsGoogleMaps3 |
16 | 16 | * |
17 | | - * @author Jeroen De Dauw |
| 17 | + * @licence GNU GPL v3 |
| 18 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
18 | 19 | */ |
19 | 20 | |
20 | 21 | if ( !defined( 'MEDIAWIKI' ) ) { |
— | — | @@ -67,6 +68,7 @@ |
68 | 69 | |
69 | 70 | $wgAutoloadClasses['MapsGoogleMaps3'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3.php'; |
70 | 71 | $wgAutoloadClasses['MapsParamGMap3Type'] = dirname( __FILE__ ) . '/Maps_ParamGMap3Type.php'; |
| 72 | + $wgAutoloadClasses['MapsParamGMap3Types'] = dirname( __FILE__ ) . '/Maps_ParamGMap3Types.php'; |
71 | 73 | $wgAutoloadClasses['MapsParamGMap3Typestyle'] = dirname( __FILE__ ) . '/Maps_ParamGMap3Typestyle.php'; |
72 | 74 | $wgAutoloadClasses['MapsParamGMap3Zoomstyle'] = dirname( __FILE__ ) . '/Maps_ParamGMap3Zoomstyle.php'; |
73 | 75 | |
Index: trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_GoogleMaps3.php |
— | — | @@ -9,7 +9,8 @@ |
10 | 10 | * @file Maps_GoogleMaps3.php |
11 | 11 | * @ingroup MapsGoogleMaps3 |
12 | 12 | * |
13 | | - * @author Jeroen De Dauw |
| 13 | + * @licence GNU GPL v3 |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
14 | 15 | */ |
15 | 16 | class MapsGoogleMaps3 extends MapsMappingService { |
16 | 17 | |
— | — | @@ -95,9 +96,10 @@ |
96 | 97 | $params['type']->setMessage( 'maps-googlemaps3-par-type' ); |
97 | 98 | |
98 | 99 | $params['types'] = new ListParameter( 'types' ); |
| 100 | + $params['types']->addDependencies( 'type' ); |
99 | 101 | $params['types']->setDefault( $egMapsGMaps3Types ); |
100 | 102 | $params['types']->addCriteria( new CriterionInArray( self::getTypeNames() ) ); |
101 | | - $params['types']->addManipulations( new MapsParamGMap3Type() ); |
| 103 | + $params['types']->addManipulations( new MapsParamGMap3Type(), new MapsParamGMap3Types() ); |
102 | 104 | $params['types']->setMessage( 'maps-googlemaps3-par-types' ); |
103 | 105 | |
104 | 106 | $params['layers'] = new ListParameter( 'layers' ); |