Permalink
Browse files

Support for removing Fusion Tables and GeoRSS/KML layers with removeL…

…ayer
  • Loading branch information...
1 parent b2cc819 commit 44f80c81835fd8ebcf842de0d123f81fbe8893e7 @hpneo committed Mar 28, 2013
Showing with 23 additions and 8 deletions.
  1. +4 −0 README.md
  2. +4 −3 examples/layers.html
  3. +15 −5 gmaps.js
View
@@ -8,6 +8,10 @@ Visit the examples in [hpneo.github.com/gmaps](http://hpneo.github.com/gmaps/)
Changelog
---------
+0.3.2
+-----------------------
+* Support for removing Fusion Tables and GeoRSS/KML layers with removeLayer
+
0.3.1
-----------------------
* Improve event binding at adding markers, polylines or polygons
View
@@ -8,9 +8,10 @@
<script src="../gmaps.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="examples.css" />
- <script>
- $(function () {
- var map = new GMaps({
+ <script type="text/javascript">
+ var map;
+ $(function () {
+ map = new GMaps({
el: "#map",
lat: -12.043333,
lng: -77.028333,
View
@@ -1,5 +1,5 @@
/*!
- * GMaps.js v0.3.1
+ * GMaps.js v0.3.2
* http://hpneo.github.com/gmaps/
*
* Copyright 2012, Gustavo Leon
@@ -1312,10 +1312,20 @@ if(window.google && window.google.maps){
}
};
- this.removeLayer = function(layerName) {
- if(this.singleLayers[layerName] !== undefined) {
- this.singleLayers[layerName].setMap(null);
- delete this.singleLayers[layerName];
+ this.removeLayer = function(layer) {
+ if(typeof(layer) == "string" && this.singleLayers[layer] !== undefined) {
+ this.singleLayers[layer].setMap(null);
+ delete this.singleLayers[layer];
+ }
+ else {
+ for(var i = 0; i < this.layers.length; i++) {
+ if(this.layers[i] === layer) {
+ this.layers[i].setMap(null);
+ this.layers.splice(i, 1);
+
+ break;
+ }
+ }
}
};

0 comments on commit 44f80c8

Please sign in to comment.