【问题标题】:There are no map type and zoom change event for Here maps. Are there any workarounds?Here地图没有地图类型和缩放更改事件。有什么解决方法吗?
【发布时间】:2018-11-17 15:33:08
【问题描述】:

我一直未能成功地为 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 控件,所以用户只能在普通地图、卫星地图和地形地图之间切换。

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

谢谢!

【问题讨论】:

    标签: here-api


    【解决方案1】:

    你可以通过监听事件“baselayerchange”来捕捉地图类型的变化:

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

    为了检测缩放变化,在你链接的答案中听“mapviewchangeend”似乎是正确的

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

    【讨论】:

    • 谢谢。但是我可以在 baselayerchange 事件中获取地图的类型(普通、卫星或地形)吗?
    【解决方案2】:

    嗯,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
                }
             });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-25
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多