繁体   English   中英

HERE Maps - 动态加载标记和缩放问题

[英]HERE Maps - dynamically load markers and zooming issue

我正在尝试使用 HERE Maps 的免费版本,并且我想在地图上动态显示标记。 即使我动态绑定数据,它也总是加载第一次加载的地图。 此外,如果我放大地图,即使我设置了缩放和居中值,它也不会回到默认版本。 如果你们中有人遇到过类似的问题,请提供一些意见。 谢谢。

请尝试使用以下代码片段来初始化地图中的相应缩放级别

 function moveMapToBerlin(map){ map.setCenter({lat:52.5159, lng:13.3777}); map.setZoom(14); } /** * Boilerplate map initialization code starts below: */ //Step 1: initialize communication with the platform // In your own code, replace variable window.apikey with your own apikey var platform = new H.service.Platform({ apikey: window.apikey }); var defaultLayers = platform.createDefaultLayers(); //Step 2: initialize a map - this map is centered over Europe var map = new H.Map(document.getElementById('map'), defaultLayers.vector.normal.map,{ center: {lat:50, lng:5}, zoom: 4, pixelRatio: window.devicePixelRatio || 1 }); // add a resize listener to make sure that the map occupies the whole container window.addEventListener('resize', () => map.getViewPort().resize()); //Step 3: make the map interactive // MapEvents enables the event system // Behavior implements default interactions for pan/zoom (also on mobile touch environments) var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map)); // Create the default UI components var ui = H.ui.UI.createDefault(map, defaultLayers); // Now use the map as required... window.onload = function () { moveMapToBerlin(map); }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM