| Index: branches/Maps0.8/includes/services/GoogleMaps3/jquery.googlemap.js |
| — | — | @@ -8,6 +8,13 @@ |
| 9 | 9 | (function( $ ){ $.fn.googlemaps = function( options ) { |
| 10 | 10 | |
| 11 | 11 | /** |
| | 12 | + * All markers that are currently on the map. |
| | 13 | + * @type {Array} |
| | 14 | + * @private |
| | 15 | + */ |
| | 16 | + this.markers = []; |
| | 17 | + |
| | 18 | + /** |
| 12 | 19 | * Creates a new marker with the provided data, |
| 13 | 20 | * adds it to the map, and returns it. |
| 14 | 21 | * @param {Object} markerData Contains the fields lat, lon, title, text and icon |
| — | — | @@ -33,12 +40,41 @@ |
| 34 | 41 | marker.openWindow = false; |
| 35 | 42 | }; |
| 36 | 43 | this.openWindow.open( map, this ); |
| 37 | | - } ); |
| | 44 | + } ); |
| 38 | 45 | } |
| 39 | 46 | |
| | 47 | + this.markers.push( marker ); |
| | 48 | + |
| 40 | 49 | return marker; |
| 41 | | - } |
| | 50 | + }; |
| 42 | 51 | |
| | 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 | + |
| 43 | 79 | var mapOptions = { |
| 44 | 80 | disableDefaultUI: true, |
| 45 | 81 | mapTypeId: eval( 'google.maps.MapTypeId.' + options.type ), |