如何使用 here.com javascript api 将地图移动到指定位置
How can I move the map to a specified location using here.com javascript api
是否有将地图移动(居中)到特定坐标的功能?我正在构建一个应用程序,在该应用程序中,如果发生事件,地图应以地图中的特定对象为中心。
是的
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 是您要移动的地图。
是否有将地图移动(居中)到特定坐标的功能?我正在构建一个应用程序,在该应用程序中,如果发生事件,地图应以地图中的特定对象为中心。
是的 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 是您要移动的地图。