http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94168

Revision: 94168
Author:   jeroendedauw
Date:     2011-08-10 17:05:54 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
finished implementing ge for gm3 and added tilt param

Modified Paths:
--------------
    trunk/extensions/Maps/Maps_Settings.php
    trunk/extensions/Maps/includes/Maps_MappingService.php
    trunk/extensions/Maps/includes/features/Maps_BaseMap.php
    trunk/extensions/Maps/includes/features/Maps_BasePointMap.php
    trunk/extensions/Maps/includes/services/GoogleMaps3/GoogleMaps3.php
    trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_GoogleMaps3.php
    trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js

Modified: trunk/extensions/Maps/Maps_Settings.php
===================================================================
--- trunk/extensions/Maps/Maps_Settings.php     2011-08-10 16:45:05 UTC (rev 
94167)
+++ trunk/extensions/Maps/Maps_Settings.php     2011-08-10 17:05:54 UTC (rev 
94168)
@@ -215,6 +215,7 @@
                
                $egMapsGMaps3Layers = array();
                
+               $egGoogleJsApiKey = '';
                
                
        # Google Maps

Modified: trunk/extensions/Maps/includes/Maps_MappingService.php
===================================================================
--- trunk/extensions/Maps/includes/Maps_MappingService.php      2011-08-10 
16:45:05 UTC (rev 94167)
+++ trunk/extensions/Maps/includes/Maps_MappingService.php      2011-08-10 
17:05:54 UTC (rev 94168)
@@ -123,6 +123,17 @@
                        $parserOrOut->addModules( $this->getResourceModules() );
                }
        }
+       
+       /**
+        * Returns a list of all config variables that should be passed to the 
JS.
+        * 
+        * @since 1.0.1
+        * 
+        * @return array
+        */
+       public function getConfigVariables() {
+               return array();
+       }
 
        /**
         * @see iMappingService::getDependencyHtml

Modified: trunk/extensions/Maps/includes/features/Maps_BaseMap.php
===================================================================
--- trunk/extensions/Maps/includes/features/Maps_BaseMap.php    2011-08-10 
16:45:05 UTC (rev 94167)
+++ trunk/extensions/Maps/includes/features/Maps_BaseMap.php    2011-08-10 
17:05:54 UTC (rev 94168)
@@ -63,13 +63,17 @@
                
                $output = $this->getMapHTML( $params, $parser, $mapName ) . 
$this->getJSON( $params, $parser, $mapName );
                
+               $configVars = Skin::makeVariablesScript( 
$this->service->getConfigVariables() );
+               
                global $wgTitle;
                if ( !is_null( $wgTitle ) && $wgTitle->isSpecialPage() ) {
                        global $wgOut;
                        $this->service->addDependencies( $wgOut );
+                       $wgOut->addScript( $configVars );
                }
                else {
-                       $this->service->addDependencies( $parser );             
        
+                       $this->service->addDependencies( $parser );
+                       $parser->getOutput()->addHeadItem( $configVars );       
                
                }
                
                return $output;

Modified: trunk/extensions/Maps/includes/features/Maps_BasePointMap.php
===================================================================
--- trunk/extensions/Maps/includes/features/Maps_BasePointMap.php       
2011-08-10 16:45:05 UTC (rev 94167)
+++ trunk/extensions/Maps/includes/features/Maps_BasePointMap.php       
2011-08-10 17:05:54 UTC (rev 94168)
@@ -39,13 +39,17 @@
                
                $output = $this->getMapHTML( $params, $parser, $mapName ) . 
$this->getJSON( $params, $parser, $mapName );
                
+               $configVars = Skin::makeVariablesScript( 
$this->service->getConfigVariables() );
+               
                global $wgTitle;
                if ( !is_null( $wgTitle ) && $wgTitle->isSpecialPage() ) {
                        global $wgOut;
                        $this->service->addDependencies( $wgOut );
+                       $wgOut->addScript( $configVars );
                }
                else {
-                       $this->service->addDependencies( $parser );             
        
+                       $this->service->addDependencies( $parser );
+                       $parser->getOutput()->addHeadItem( $configVars );       
                
                }
                
                return $output;

Modified: trunk/extensions/Maps/includes/services/GoogleMaps3/GoogleMaps3.php
===================================================================
--- trunk/extensions/Maps/includes/services/GoogleMaps3/GoogleMaps3.php 
2011-08-10 16:45:05 UTC (rev 94167)
+++ trunk/extensions/Maps/includes/services/GoogleMaps3/GoogleMaps3.php 
2011-08-10 17:05:54 UTC (rev 94168)
@@ -49,7 +49,7 @@
        'remoteBasePath' => $egMapsScriptPath .  
'/includes/services/GoogleMaps3/earth',        
        'group' => 'ext.maps',
        'scripts' => array(
-               'googleearth-compiled.js',
+               'googleearth.js',
        ),
 );
 

Modified: 
trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_GoogleMaps3.php
===================================================================
--- trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_GoogleMaps3.php    
2011-08-10 16:45:05 UTC (rev 94167)
+++ trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_GoogleMaps3.php    
2011-08-10 17:05:54 UTC (rev 94168)
@@ -144,6 +144,11 @@
                $params['resizable'] = new Parameter( 'resizable', 
Parameter::TYPE_BOOLEAN );
                $params['resizable']->setDefault( $egMapsResizableByDefault, 
false );
                $params['resizable']->setMessage( 'maps-par-resizable' );
+               
+               $egMapsGMaps3DefaultTilt = 15; // TODO
+               $params['tilt'] = new Parameter( 'tilt', 
Parameter::TYPE_INTEGER );
+               $params['tilt']->setDefault( $egMapsGMaps3DefaultTilt, false );
+               $params['tilt']->setMessage( 'maps-par-tilt' );
        }
        
        /**
@@ -240,6 +245,20 @@
                        parent::getResourceModules(),
                        array( 'ext.maps.googlemaps3' )
                );
-       }       
+       }
+
+       /**
+        * Returns a list of all config variables that should be passed to the 
JS.
+        * 
+        * @since 1.0.1
+        * 
+        * @return array
+        */
+       public final function getConfigVariables() {
+               return parent::getConfigVariables() 
+                       + array(
+                               'egGoogleJsApiKey' => 
$GLOBALS['egGoogleJsApiKey']
+                       );
+       }
        
 }

Modified: 
trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js
===================================================================
--- trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js     
2011-08-10 16:45:05 UTC (rev 94167)
+++ trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js     
2011-08-10 17:05:54 UTC (rev 94168)
@@ -175,9 +175,23 @@
        }
        
        if ( showEarth ) {
-               mw.loader.using( 'ext.maps.gm3.earth', function() {
-                       var ge = new GoogleEarth( map );
-               } );            
+               $.getScript(
+                       'https://www.google.com/jsapi?key=' + mw.config.get( 
'egGoogleJsApiKey' ),
+                       function( data, textStatus ) {
+                               google.load( 'earth', '1', { callback: 
function() {
+                                       mw.loader.using( 'ext.maps.gm3.earth', 
function() {
+                                               if ( google.earth.isSupported() 
) {
+                                                       var ge = new 
GoogleEarth( map );
+                                                       
+                                                       var lookAt = 
ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
+
+                                                       
lookAt.setTilt(lookAt.getTilt() + options.tilt);
+                                                       
ge.getView().setAbstractView(lookAt);                                           
        
+                                               }
+                                       } );    
+                               } } );
+                       }
+               );
        }
        
        for ( i = options.fusiontables.length - 1; i >= 0; i-- ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to