r94168 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94167‎ | r94168 | r94169 >
Date:17:05, 10 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
finished implementing ge for gm3 and added tilt param
Modified paths:
  • /trunk/extensions/Maps/Maps_Settings.php (modified) (history)
  • /trunk/extensions/Maps/includes/Maps_MappingService.php (modified) (history)
  • /trunk/extensions/Maps/includes/features/Maps_BaseMap.php (modified) (history)
  • /trunk/extensions/Maps/includes/features/Maps_BasePointMap.php (modified) (history)
  • /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/Maps_Settings.php
@@ -215,6 +215,7 @@
216216
217217 $egMapsGMaps3Layers = array();
218218
 219+ $egGoogleJsApiKey = '';
219220
220221
221222 # Google Maps
Index: trunk/extensions/Maps/includes/Maps_MappingService.php
@@ -123,6 +123,17 @@
124124 $parserOrOut->addModules( $this->getResourceModules() );
125125 }
126126 }
 127+
 128+ /**
 129+ * Returns a list of all config variables that should be passed to the JS.
 130+ *
 131+ * @since 1.0.1
 132+ *
 133+ * @return array
 134+ */
 135+ public function getConfigVariables() {
 136+ return array();
 137+ }
127138
128139 /**
129140 * @see iMappingService::getDependencyHtml
Index: trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js
@@ -175,9 +175,23 @@
176176 }
177177
178178 if ( showEarth ) {
179 - mw.loader.using( 'ext.maps.gm3.earth', function() {
180 - var ge = new GoogleEarth( map );
181 - } );
 179+ $.getScript(
 180+ 'https://www.google.com/jsapi?key=' + mw.config.get( 'egGoogleJsApiKey' ),
 181+ function( data, textStatus ) {
 182+ google.load( 'earth', '1', { callback: function() {
 183+ mw.loader.using( 'ext.maps.gm3.earth', function() {
 184+ if ( google.earth.isSupported() ) {
 185+ var ge = new GoogleEarth( map );
 186+
 187+ var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
 188+
 189+ lookAt.setTilt(lookAt.getTilt() + options.tilt);
 190+ ge.getView().setAbstractView(lookAt);
 191+ }
 192+ } );
 193+ } } );
 194+ }
 195+ );
182196 }
183197
184198 for ( i = options.fusiontables.length - 1; i >= 0; i-- ) {
Index: trunk/extensions/Maps/includes/services/GoogleMaps3/GoogleMaps3.php
@@ -49,7 +49,7 @@
5050 'remoteBasePath' => $egMapsScriptPath . '/includes/services/GoogleMaps3/earth',
5151 'group' => 'ext.maps',
5252 'scripts' => array(
53 - 'googleearth-compiled.js',
 53+ 'googleearth.js',
5454 ),
5555 );
5656
Index: trunk/extensions/Maps/includes/services/GoogleMaps3/Maps_GoogleMaps3.php
@@ -144,6 +144,11 @@
145145 $params['resizable'] = new Parameter( 'resizable', Parameter::TYPE_BOOLEAN );
146146 $params['resizable']->setDefault( $egMapsResizableByDefault, false );
147147 $params['resizable']->setMessage( 'maps-par-resizable' );
 148+
 149+ $egMapsGMaps3DefaultTilt = 15; // TODO
 150+ $params['tilt'] = new Parameter( 'tilt', Parameter::TYPE_INTEGER );
 151+ $params['tilt']->setDefault( $egMapsGMaps3DefaultTilt, false );
 152+ $params['tilt']->setMessage( 'maps-par-tilt' );
148153 }
149154
150155 /**
@@ -240,6 +245,20 @@
241246 parent::getResourceModules(),
242247 array( 'ext.maps.googlemaps3' )
243248 );
244 - }
 249+ }
 250+
 251+ /**
 252+ * Returns a list of all config variables that should be passed to the JS.
 253+ *
 254+ * @since 1.0.1
 255+ *
 256+ * @return array
 257+ */
 258+ public final function getConfigVariables() {
 259+ return parent::getConfigVariables()
 260+ + array(
 261+ 'egGoogleJsApiKey' => $GLOBALS['egGoogleJsApiKey']
 262+ );
 263+ }
245264
246265 }
Index: trunk/extensions/Maps/includes/features/Maps_BasePointMap.php
@@ -39,13 +39,17 @@
4040
4141 $output = $this->getMapHTML( $params, $parser, $mapName ) . $this->getJSON( $params, $parser, $mapName );
4242
 43+ $configVars = Skin::makeVariablesScript( $this->service->getConfigVariables() );
 44+
4345 global $wgTitle;
4446 if ( !is_null( $wgTitle ) && $wgTitle->isSpecialPage() ) {
4547 global $wgOut;
4648 $this->service->addDependencies( $wgOut );
 49+ $wgOut->addScript( $configVars );
4750 }
4851 else {
49 - $this->service->addDependencies( $parser );
 52+ $this->service->addDependencies( $parser );
 53+ $parser->getOutput()->addHeadItem( $configVars );
5054 }
5155
5256 return $output;
Index: trunk/extensions/Maps/includes/features/Maps_BaseMap.php
@@ -63,13 +63,17 @@
6464
6565 $output = $this->getMapHTML( $params, $parser, $mapName ) . $this->getJSON( $params, $parser, $mapName );
6666
 67+ $configVars = Skin::makeVariablesScript( $this->service->getConfigVariables() );
 68+
6769 global $wgTitle;
6870 if ( !is_null( $wgTitle ) && $wgTitle->isSpecialPage() ) {
6971 global $wgOut;
7072 $this->service->addDependencies( $wgOut );
 73+ $wgOut->addScript( $configVars );
7174 }
7275 else {
73 - $this->service->addDependencies( $parser );
 76+ $this->service->addDependencies( $parser );
 77+ $parser->getOutput()->addHeadItem( $configVars );
7478 }
7579
7680 return $output;

Follow-up revisions

RevisionCommit summaryAuthorDate
r94169fu r94168jeroendedauw17:06, 10 August 2011
r94175fu r94168jeroendedauw17:59, 10 August 2011