我如何使用here.com javascript api将地图移动到指定位置

How can I move the map to a specified location using here.com javascript api

本文关键字:移动 地图 位置 定位 api 何使用 here com javascript      更新时间:2023-09-26

是否存在将地图移动(居中)到特定坐标的函数?我正在构建一个应用程序,在这个应用程序中,如果给定一个事件,地图应该以地图中的特定对象为中心。

map. setcenter ()方法和map. setzoom ()方法能够控制地图的位置。

一个例子可以是:

/**
 * Moves the map to display over Berlin
 *
 * @param  {H.Map} map      A HERE Map instance within the application
 */
function moveMapToBerlin(map) {
  map.setCenter({
    lat: 52.5159,
    lng: 13.3777
  });
  map.setZoom(14);
}

其中map为要移动的地图