Last active
March 1, 2019 06:32
-
-
Save KMR-zoar/063a49ece8a2d7108ecc5c2efd4fce93 to your computer and use it in GitHub Desktop.
Remove layers added by ol-geocoder seach
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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