Skip to content

Instantly share code, notes, and snippets.

@KMR-zoar
Last active March 1, 2019 06:32
Show Gist options
  • Save KMR-zoar/063a49ece8a2d7108ecc5c2efd4fce93 to your computer and use it in GitHub Desktop.
Save KMR-zoar/063a49ece8a2d7108ecc5c2efd4fce93 to your computer and use it in GitHub Desktop.
Remove layers added by ol-geocoder seach
function remove_search_marker() {
var remove_layer_name = 'geocoder-layer';
var layers_to_remove = [];
map.getLayers().forEach(function(layer) {
var layer_name = layer.getProperties().name;
if (layer_name && layer_name.match(remove_layer_name)) {
layers_to_remove.push(layer);
}
});
for (var i = 0; i < layers_to_remove.length; i++) {
map.removeLayer(layers_to_remove[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment