Here 地图没有地图类型和缩放更改事件。有什么解决方法吗?

There are no map type and zoom change event for Here maps. Are there any workarounds?

我一直在为 Here 地图项目(web、js api)寻找缩放更改和地图类型更改事件,但没有成功:https://developer.here.com/documentation/maps/topics/events.html

我在这里找到了缩放更改事件的解决方法:Zoom changed event for nokia Here maps

但是我找不到任何关于地图类型更改的信息。我什至找不到像 map.getMapType() 或 map.getScheme() 这样的函数,我可以尝试将其添加到之前的解决方法中。

我使用的是基本的 ui 控件,因此用户只能在普通地图、卫星地图和地形地图之间切换。

此事件是否存在,如果不存在,是否有解决缩放更改事件的方法?

谢谢!

您可以通过侦听事件来捕获地图类型更改 "baselayerchange":

map.addEventListener('baselayerchange', () => {
  // ...
})

为了检测缩放变化,听取 "mapviewchangeend" 您正在链接的答案似乎是正确的

map.addEventListener('mapviewchangeend', () => {
   console.log(map.getZoom())
}

好吧,18个月后我又遇到了这个问题,终于找到了解决办法。这是:

map.addEventListener('baselayerchange', function(){
            var mapType = map.getBaseLayer().getProvider().copyrightKey_;
            if (mapType=="hybrid") {
                // case hybrid
                });
            }
            else if (mapType=="terrain") {
                // case terrain
                });
            }
            else {
               // case normal
            }
         });