Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44f80c8

Browse files
committed
Support for removing Fusion Tables and GeoRSS/KML layers with removeLayer
1 parent b2cc819 commit 44f80c8

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Visit the examples in [hpneo.github.com/gmaps](http://hpneo.github.com/gmaps/)
88
Changelog
99
---------
1010

11+
0.3.2
12+
-----------------------
13+
* Support for removing Fusion Tables and GeoRSS/KML layers with removeLayer
14+
1115
0.3.1
1216
-----------------------
1317
* Improve event binding at adding markers, polylines or polygons

examples/layers.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
<script src="../gmaps.js"></script>
99
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css" />
1010
<link rel="stylesheet" type="text/css" href="examples.css" />
11-
<script>
12-
$(function () {
13-
var map = new GMaps({
11+
<script type="text/javascript">
12+
var map;
13+
$(function () {
14+
map = new GMaps({
1415
el: "#map",
1516
lat: -12.043333,
1617
lng: -77.028333,

gmaps.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* GMaps.js v0.3.1
2+
* GMaps.js v0.3.2
33
* http://hpneo.github.com/gmaps/
44
*
55
* Copyright 2012, Gustavo Leon
@@ -1312,10 +1312,20 @@ if(window.google && window.google.maps){
13121312
}
13131313
};
13141314

1315-
this.removeLayer = function(layerName) {
1316-
if(this.singleLayers[layerName] !== undefined) {
1317-
this.singleLayers[layerName].setMap(null);
1318-
delete this.singleLayers[layerName];
1315+
this.removeLayer = function(layer) {
1316+
if(typeof(layer) == "string" && this.singleLayers[layer] !== undefined) {
1317+
this.singleLayers[layer].setMap(null);
1318+
delete this.singleLayers[layer];
1319+
}
1320+
else {
1321+
for(var i = 0; i < this.layers.length; i++) {
1322+
if(this.layers[i] === layer) {
1323+
this.layers[i].setMap(null);
1324+
this.layers.splice(i, 1);
1325+
1326+
break;
1327+
}
1328+
}
13191329
}
13201330
};
13211331

0 commit comments

Comments
 (0)