r94125 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94124‎ | r94125 | r94126 >
Date:16:54, 9 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
adding ge support for gm3
Modified paths:
  • /trunk/extensions/Maps/includes/services/GoogleMaps3/GoogleMaps3.php (modified) (history)
  • /trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_GoogleMaps3.php (modified) (history)
  • /trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js
@@ -85,7 +85,7 @@
8686
8787 var mapOptions = {
8888 disableDefaultUI: true,
89 - mapTypeId: eval( 'google.maps.MapTypeId.' + options.type )
 89+ mapTypeId: options.type == 'earth' ? google.maps.MapTypeId.SATELLITE : eval( 'google.maps.MapTypeId.' + options.type )
9090 };
9191 this.options = options;
9292
@@ -119,14 +119,58 @@
120120 }
121121
122122 // If there are any non-Google KML/KMZ layers, load the geoxml library and use it to add these layers.
123 - mw.loader.using( 'ext.maps.gm3.geoxml', function() {
124 - var geoXml = new geoXML3.parser( { map: map } );
 123+ if ( options.kml.length != 0 ) {
 124+ mw.loader.using( 'ext.maps.gm3.geoxml', function() {
 125+ var geoXml = new geoXML3.parser( { map: map } );
 126+
 127+ for ( i = options.kml.length - 1; i >= 0; i-- ) {
 128+ geoXml.parse( options.kml[i] );
 129+ }
 130+ } );
 131+ }
 132+
 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 ) ) {
 135+ mw.loader.using( 'ext.maps.gm3.earth', function() {
 136+ var ge = new GoogleEarth( map );
 137+ } );
125138
126 - for ( i = options.kml.length - 1; i >= 0; i-- ) {
127 - geoXml.parse( options.kml[i] );
 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+ };
128168 }
129 - } );
 169+
 170+ options.types.filter( function( element, index, array ) { return element != 'earth'; } );
 171+ }
130172
 173+ // TODO: map types
 174+
131175 for ( i = options.fusiontables.length - 1; i >= 0; i-- ) {
132176 var ftLayer = new google.maps.FusionTablesLayer( options.fusiontables[i], { map: map } );
133177 }
Index: trunk/extensions/Maps/includes/services/GoogleMaps3/GoogleMaps3.php
@@ -43,6 +43,15 @@
4444 ),
4545 );
4646
 47+$wgResourceModules['ext.maps.gm3.earth'] = array(
 48+ 'localBasePath' => dirname( __FILE__ ) . '/earth',
 49+ 'remoteBasePath' => $egMapsScriptPath . '/includes/services/GoogleMaps3/earth',
 50+ 'group' => 'ext.maps',
 51+ 'scripts' => array(
 52+ 'googleearth-compiled.js',
 53+ ),
 54+);
 55+
4756 $wgHooks['MappingServiceLoad'][] = 'efMapsInitGoogleMaps3';
4857
4958 /**
Index: trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_GoogleMaps3.php
@@ -26,7 +26,8 @@
2727 'satellite' => 'SATELLITE',
2828 'hybrid' => 'HYBRID',
2929 'terrain' => 'TERRAIN',
30 - 'physical' => 'TERRAIN'
 30+ 'physical' => 'TERRAIN',
 31+ 'earth' => 'earth'
3132 );
3233
3334 /**