Reputation: 49714
I want my application to do something when the base layer has changed.
Is it possible to handle/catch that event in OpenLayers 2?
Upvotes: 1
Views: 786
Reputation: 12571
Yes, it is possible:
map.events.register("changebaselayer", this, function (obj) {
if (obj.layer.name == 'layer_name') {
//do something if new base layer is equal to layer_name
....
}
});
You can see all the possible events you can hook into in the source for OpenLayers/Map.js although the actual event will be triggered by the LayerSwitcher.
Upvotes: 1