Nokia Maps TypeSelector events
-
21-12-2019 - |
Question
I added a type selector (nokia.maps.map.component.TypeSelector) to my nokia map, but I need to attach to an event that gets fired as soon as the user changes the map type, but nokia doesn't seem to list any events for this object?
I created a little horrible (less than ideal) workaround (seen below)
$('.nm_dropDownMenu dd').on('click', function () {
switch ($(this).prop('class')) {
case "nm_satellite":
// do something
break;
case "nm_terrain":
// do something
break;
default:
break;
}
});
Any ideas?
Solution
The TypeSelector
itself doesn't have any events, since it is the Display
that is changing.
Just add an observer to the baseMapType
property as shown:
map.components.add(new nokia.maps.map.component.TypeSelector());
map.addObserver("baseMapType",
function (obj, key, newValue, oldValue) {
alert(newValue.label);
}
);
By the way, the 2.2.3 documentation is a couple of years out of date - the latest version of the documentation can be found on the developer.here.com website.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow