r84050 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:< r84049‎ | r84050 | r84051 >
Date:19:58, 15 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added marker removal functions for gmaps3
Modified paths:
  • /branches/Maps0.8/includes/services/GoogleMaps3/jquery.googlemap.js (modified) (history)

Diff [purge]

Index: branches/Maps0.8/includes/services/GoogleMaps3/jquery.googlemap.js
——@@ -8,6 +8,13 @@
99 (function( $ ){ $.fn.googlemaps = function( options ) {
1010
1111 /**
 12+ * All markers that are currently on the map.
 13+ * @type {Array}
 14+ * @private
 15+ */
 16+ this.markers = [];
 17+
 18+ /**
1219 * Creates a new marker with the provided data,
1320 * adds it to the map, and returns it.
1421 * @param {Object} markerData Contains the fields lat, lon, title, text and icon
——@@ -33,12 +40,41 @@
3441 marker.openWindow = false;
3542 };
3643 this.openWindow.open( map, this );
37 - } );
 44+ } );
3845 }
3946
 47+ this.markers.push( marker );
 48+
4049 return marker;
41 - }
 50+ };
4251
 52+ /**
 53+ * Removes a single marker from the map.
 54+ * @param {google.maps.Marker} marker The marker to remove.
 55+ */
 56+ this.removeMarker = function( marker ) {
 57+ marker.setMap( null );
 58+
 59+ for ( var i = this.markers.length - 1; i >= 0; i-- ) {
 60+ if ( this.markers[i] === marker ) {
 61+ delete this.markers[i];
 62+ break;
 63+ }
 64+ }
 65+
 66+ delete marker;
 67+ };
 68+
 69+ /**
 70+ * Removes all markers from the map.
 71+ */
 72+ this.removeMarkers = function() {
 73+ for ( var i = this.markers.length - 1; i >= 0; i-- ) {
 74+ this.markers[i].setMap( null );
 75+ }
 76+ this.markers = [];
 77+ };
 78+
4379 var mapOptions = {
4480 disableDefaultUI: true,
4581 mapTypeId: eval( 'google.maps.MapTypeId.' + options.type ),

Status & tagging log