http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98065
Revision: 98065
Author: jeroendedauw
Date: 2011-09-25 13:54:55 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
fix js issue
Modified Paths:
--------------
trunk/extensions/Maps/RELEASE-NOTES
trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js
Modified: trunk/extensions/Maps/RELEASE-NOTES
===================================================================
--- trunk/extensions/Maps/RELEASE-NOTES 2011-09-25 13:37:16 UTC (rev 98064)
+++ trunk/extensions/Maps/RELEASE-NOTES 2011-09-25 13:54:55 UTC (rev 98065)
@@ -11,6 +11,7 @@
(2011-0x-xx)
* Updated OpenLayers from 2.10 to 2.11.
+* Fixed bug in adding adittional markers for Google Maps v3 (mainly affecting
the Semantic Maps form input).
=== Maps 1.0.3 ===
(2011-09-14)
Modified:
trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js
===================================================================
--- trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js
2011-09-25 13:37:16 UTC (rev 98064)
+++ trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js
2011-09-25 13:54:55 UTC (rev 98065)
@@ -9,6 +9,9 @@
var _this = this;
+ this.map = null;
+ this.options = options;
+
/**
* All markers that are currently on the map.
* @type {Array}
@@ -46,10 +49,11 @@
this.openWindow.closeclick = function() {
marker.openWindow = false;
};
- this.openWindow.open( map, this );
+ this.openWindow.open( _this.map, this );
} );
}
+ marker.setMap( this.map );
this.markers.push( marker );
return marker;
@@ -106,9 +110,9 @@
};
this.addOverlays = function() {
- for ( i in this.markers ) {
- this.markers[i].setMap( map );
- }
+// for ( i in this.markers ) {
+// this.markers[i].setMap( map );
+// }
// Add the Google KML/KMZ layers.
for ( i = options.gkml.length - 1; i >= 0; i-- ) {
@@ -133,172 +137,174 @@
}
};
- this.options = options;
-
- var showEarth = $.inArray( 'earth', options.types ) !== -1;
-
- // If there are any non-Google KML/KMZ layers, load the geoxml library
and use it to add these layers.
- if ( showEarth ) {
- this.removeEarthType();
- showEarth = mw.config.get( 'egGoogleJsApiKey' ) != '';
- }
-
- var mapOptions = {
- disableDefaultUI: true,
- mapTypeId: options.type == 'earth' ?
google.maps.MapTypeId.SATELLITE : eval( 'google.maps.MapTypeId.' + options.type
)
- };
-
- // Map controls
- mapOptions.panControl = $.inArray( 'pan', options.controls ) != -1;
- mapOptions.zoomControl = $.inArray( 'zoom', options.controls ) != -1;
- mapOptions.mapTypeControl = $.inArray( 'type', options.controls ) != -1;
- mapOptions.scaleControl = $.inArray( 'scale', options.controls ) != -1;
- mapOptions.streetViewControl = $.inArray( 'streetview',
options.controls ) != -1;
+ this.setup = function() {
+ var showEarth = $.inArray( 'earth', options.types ) !== -1;
+
+ // If there are any non-Google KML/KMZ layers, load the geoxml
library and use it to add these layers.
+ if ( showEarth ) {
+ this.removeEarthType();
+ showEarth = mw.config.get( 'egGoogleJsApiKey' ) != '';
+ }
+
+ var mapOptions = {
+ disableDefaultUI: true,
+ mapTypeId: options.type == 'earth' ?
google.maps.MapTypeId.SATELLITE : eval( 'google.maps.MapTypeId.' + options.type
)
+ };
+
+ // Map controls
+ mapOptions.panControl = $.inArray( 'pan', options.controls ) !=
-1;
+ mapOptions.zoomControl = $.inArray( 'zoom', options.controls )
!= -1;
+ mapOptions.mapTypeControl = $.inArray( 'type', options.controls
) != -1;
+ mapOptions.scaleControl = $.inArray( 'scale', options.controls
) != -1;
+ mapOptions.streetViewControl = $.inArray( 'streetview',
options.controls ) != -1;
- for ( i in options.types ) {
- options.types[i] = eval( 'google.maps.MapTypeId.' +
options.types[i] );
- }
-
- // Map control styles
- mapOptions.zoomControlOptions = { style: eval(
'google.maps.ZoomControlStyle.' + options.zoomstyle ) };
- mapOptions.mapTypeControlOptions = {
- style: eval( 'google.maps.MapTypeControlStyle.' +
options.typestyle ),
- mapTypeIds: options.types
- };
+ for ( i in options.types ) {
+ options.types[i] = eval( 'google.maps.MapTypeId.' +
options.types[i] );
+ }
+
+ // Map control styles
+ mapOptions.zoomControlOptions = { style: eval(
'google.maps.ZoomControlStyle.' + options.zoomstyle ) };
+ mapOptions.mapTypeControlOptions = {
+ style: eval( 'google.maps.MapTypeControlStyle.' +
options.typestyle ),
+ mapTypeIds: options.types
+ };
- var map = new google.maps.Map( this.get( 0 ), mapOptions );
- this.map = map;
-
- if ( !options.locations ) {
- options.locations = [];
- }
-
- // Add the markers.
- for ( var i = options.locations.length - 1; i >= 0; i-- ) {
- this.addMarker( options.locations[i] );
- }
-
- for ( i = options.fusiontables.length - 1; i >= 0; i-- ) {
- var ftLayer = new google.maps.FusionTablesLayer(
options.fusiontables[i], { map: map } );
- }
-
- var layerMapping = {
- 'traffic': 'new google.maps.TrafficLayer()',
- 'bicycling': 'new google.maps.BicyclingLayer()'
- };
-
- for ( i = options.layers.length - 1; i >= 0; i-- ) {
- var layer = eval( layerMapping[options.layers[i]] );
- layer.setMap( map );
- }
-
- var bounds;
-
- if ( ( options.centre === false || options.zoom === false ) &&
options.locations.length > 1 ) {
- bounds = new google.maps.LatLngBounds();
+ var map = new google.maps.Map( this.get( 0 ), mapOptions );
+ this.map = map;
+
+ if ( !options.locations ) {
+ options.locations = [];
+ }
+
+ // Add the markers.
+ for ( var i = options.locations.length - 1; i >= 0; i-- ) {
+ this.addMarker( options.locations[i] );
+ }
+
+ for ( i = options.fusiontables.length - 1; i >= 0; i-- ) {
+ var ftLayer = new google.maps.FusionTablesLayer(
options.fusiontables[i], { map: map } );
+ }
+
+ var layerMapping = {
+ 'traffic': 'new google.maps.TrafficLayer()',
+ 'bicycling': 'new google.maps.BicyclingLayer()'
+ };
+
+ for ( i = options.layers.length - 1; i >= 0; i-- ) {
+ var layer = eval( layerMapping[options.layers[i]] );
+ layer.setMap( map );
+ }
+
+ var bounds;
+
+ if ( ( options.centre === false || options.zoom === false ) &&
options.locations.length > 1 ) {
+ bounds = new google.maps.LatLngBounds();
- for ( var i = this.markers.length - 1; i >= 0; i-- ) {
- bounds.extend( this.markers[i].getPosition() );
+ for ( var i = this.markers.length - 1; i >= 0; i-- ) {
+ bounds.extend( this.markers[i].getPosition() );
+ }
}
- }
-
- if ( options.zoom === false ) {
- map.fitBounds( bounds );
- }
- else {
- map.setZoom( options.zoom );
- }
-
- var centre;
-
- if ( options.centre === false ) {
- if ( options.locations.length > 1 ) {
- centre = bounds.getCenter();
+
+ if ( options.zoom === false ) {
+ map.fitBounds( bounds );
}
- else if ( options.locations.length == 1 ) {
- centre = new google.maps.LatLng(
options.locations[0].lat, options.locations[0].lon );
+ else {
+ map.setZoom( options.zoom );
}
+
+ var centre;
+
+ if ( options.centre === false ) {
+ if ( options.locations.length > 1 ) {
+ centre = bounds.getCenter();
+ }
+ else if ( options.locations.length == 1 ) {
+ centre = new google.maps.LatLng(
options.locations[0].lat, options.locations[0].lon );
+ }
+ else {
+ centre = new google.maps.LatLng( 0, 0 );
+ }
+ }
else {
- centre = new google.maps.LatLng( 0, 0 );
+ centre = new google.maps.LatLng( options.centre.lat,
options.centre.lon );
}
- }
- else {
- centre = new google.maps.LatLng( options.centre.lat,
options.centre.lon );
- }
-
- map.setCenter( centre );
-
- if ( showEarth ) {
- $.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 setTilt =
function() {
+
+ map.setCenter( centre );
+
+ if ( showEarth ) {
+ $.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 setTilt =
function() {
+
+ if (
ge.getInstance() !== undefined ) {
+
+
var center = map.getCenter();
+
var lookAt = ge.instance_.createLookAt('');
+
var range = Math.pow(2, GoogleEarth.MAX_EARTH_ZOOM_ - map.getZoom());
+
lookAt.setRange(range);
+
lookAt.setLatitude(center.lat());
+
lookAt.setLongitude(center.lng());
+
lookAt.setHeading(0);
+
lookAt.setAltitude(0);
+
+
// Teleport to the pre-tilt view immediately.
+
ge.instance_.getOptions().setFlyToSpeed(5);
+
ge.instance_.getView().setAbstractView(lookAt);
+
lookAt.setTilt(options.tilt);
+
// Fly to the tilt at regular speed in 200ms
+
ge.instance_.getOptions().setFlyToSpeed(0.75);
+
window.setTimeout(function() {
+
ge.instance_.getView().setAbstractView(lookAt);
+
}, 200);
+
// Set the flyto speed back to default after the animation starts.
+
window.setTimeout(function() {
+
ge.instance_.getOptions().setFlyToSpeed(1);
+
}, 250);
+
+ }
+ else {
+
setTimeout( function() { setTilt(); }, 100 );
+ }
+ };
- if (
ge.getInstance() !== undefined ) {
-
- var
center = map.getCenter();
- var
lookAt = ge.instance_.createLookAt('');
- var
range = Math.pow(2, GoogleEarth.MAX_EARTH_ZOOM_ - map.getZoom());
-
lookAt.setRange(range);
-
lookAt.setLatitude(center.lat());
-
lookAt.setLongitude(center.lng());
-
lookAt.setHeading(0);
-
lookAt.setAltitude(0);
-
- //
Teleport to the pre-tilt view immediately.
-
ge.instance_.getOptions().setFlyToSpeed(5);
-
ge.instance_.getView().setAbstractView(lookAt);
-
lookAt.setTilt(options.tilt);
- //
Fly to the tilt at regular speed in 200ms
-
ge.instance_.getOptions().setFlyToSpeed(0.75);
-
window.setTimeout(function() {
-
ge.instance_.getView().setAbstractView(lookAt);
- },
200);
- //
Set the flyto speed back to default after the animation starts.
-
window.setTimeout(function() {
-
ge.instance_.getOptions().setFlyToSpeed(1);
- },
250);
-
+ if (
options.type == 'earth' ) {
+
map.setMapTypeId( GoogleEarth.MAP_TYPE_ID );
+
setTilt();
}
else {
-
setTimeout( function() { setTilt(); }, 100 );
+
google.maps.event.addListenerOnce( map, 'maptypeid_changed', function() {
setTilt(); } );
}
- };
+ }
- if ( options.type ==
'earth' ) {
-
map.setMapTypeId( GoogleEarth.MAP_TYPE_ID );
- setTilt();
- }
- else {
-
google.maps.event.addListenerOnce( map, 'maptypeid_changed', function() {
setTilt(); } );
- }
- }
-
- _this.addOverlays();
- } );
- } } );
- }
- );
- }
- else {
- google.maps.event.addListenerOnce( map, 'tilesloaded',
function() { _this.addOverlays(); } );
- }
-
- if ( options.autoinfowindows ) {
- for ( var i = this.markers.length - 1; i >= 0; i-- ) {
- google.maps.event.trigger( this.markers[i], 'click' );
+ _this.addOverlays();
+ } );
+ } } );
+ }
+ );
+ }
+ else {
+ google.maps.event.addListenerOnce( map, 'tilesloaded',
function() { _this.addOverlays(); } );
+ }
+
+ if ( options.autoinfowindows ) {
+ for ( var i = this.markers.length - 1; i >= 0; i-- ) {
+ google.maps.event.trigger( this.markers[i],
'click' );
+ }
+ }
+
+ if ( options.resizable ) {
+ mw.loader.using( 'ext.maps.resizable', function() {
+ _this.resizable();
+ } );
}
- }
+ };
- if ( options.resizable ) {
- mw.loader.using( 'ext.maps.resizable', function() {
- _this.resizable();
- } );
- }
+ this.setup();
return this;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs