Permalink
Browse files

adding a gmap.remove_polygons function

  • Loading branch information...
1 parent 8e815c5 commit a4e1832577572da2b9147ea2bc30fcc3d94da20f @albertsun committed Jan 7, 2012
Showing with 30 additions and 11 deletions.
  1. +13 −4 gmap-features.js
  2. +4 −3 gmap-features.min.js
  3. +13 −4 src/gmap-loadpolygons.js
View
@@ -346,8 +346,6 @@ var gmap = gmap || {};
} else {
data = data.features;
}
-
-
if (params.unselected_opts) {
gmap._.extend(gmap.Feature.prototype._unselected_poly_options, params.unselected_opts);
}
@@ -382,12 +380,10 @@ var gmap = gmap || {};
if (params.getColor) {
opts.color = params.getColor(data[i].properties);
}
-
// Responsive polygon options
opts.responsive_unselected_opts = params.responsive_unselected_opts;
opts.responsive_highlighted_opts = params.responsive_highlighted_opts;
opts.responsive_selected_opts = params.responsive_selected_opts;
-
// Callbacks
opts.highlightCallback = params.highlightCallback;
opts.selectCallback = params.selectCallback;
@@ -397,4 +393,17 @@ var gmap = gmap || {};
return self;
};
+
+ /**
+ * Pass this the a dictionary as returned by load_polygons and it'll remove them from the map.
+ */
+ gmap.remove_polygons = function(features) {
+ for (var prop in features) {
+ if (features.hasOwnProperty(prop)) {
+ features[prop].remove();
+ delete features[prop];
+ }
+ }
+ return features;
+ };
}());
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -37,8 +37,6 @@ var gmap = gmap || {};
} else {
data = data.features;
}
-
-
if (params.unselected_opts) {
gmap._.extend(gmap.Feature.prototype._unselected_poly_options, params.unselected_opts);
}
@@ -73,12 +71,10 @@ var gmap = gmap || {};
if (params.getColor) {
opts.color = params.getColor(data[i].properties);
}
-
// Responsive polygon options
opts.responsive_unselected_opts = params.responsive_unselected_opts;
opts.responsive_highlighted_opts = params.responsive_highlighted_opts;
opts.responsive_selected_opts = params.responsive_selected_opts;
-
// Callbacks
opts.highlightCallback = params.highlightCallback;
opts.selectCallback = params.selectCallback;
@@ -88,4 +84,17 @@ var gmap = gmap || {};
return self;
};
+
+ /**
+ * Pass this the a dictionary as returned by load_polygons and it'll remove them from the map.
+ */
+ gmap.remove_polygons = function(features) {
+ for (var prop in features) {
+ if (features.hasOwnProperty(prop)) {
+ features[prop].remove();
+ delete features[prop];
+ }
+ }
+ return features;
+ };
}());

0 comments on commit a4e1832

Please sign in to comment.