Maps 此处/诺基亚地图标记并非始终显示
我有几个地图标记,位于各地,我想自动缩放,以显示他们所有 我的代码应该工作得很好,但有时似乎取决于地图标记的位置,它并不总是正确缩放以显示标记 下面是一个示例标记来说明问题:使用以下标记位置:Maps 此处/诺基亚地图标记并非始终显示,maps,markers,here-api,Maps,Markers,Here Api,我有几个地图标记,位于各地,我想自动缩放,以显示他们所有 我的代码应该工作得很好,但有时似乎取决于地图标记的位置,它并不总是正确缩放以显示标记 下面是一个示例标记来说明问题:使用以下标记位置: // Add markers to the map for each location addMarker(1, "Hello 1", [-18,178.333]); addMarker(2, "Hello 2", [-18.5,180]); addMarker(3, "Hello 3", [-18.5,
// Add markers to the map for each location
addMarker(1, "Hello 1", [-18,178.333]);
addMarker(2, "Hello 2", [-18.5,180]);
addMarker(3, "Hello 3", [-18.5,-178.333]);
自动变焦完全出错了,似乎在某处的海面上被放大了
在我看来,这是一个bug,因为它似乎取决于地图标记的位置以及缩放是否正确
更新
我已经创建了一个更简单的版本,使用heredeveloper演示可以缩放到一组标记
您需要缩小地图以查看默认情况下应在视图中的标记
谢谢这对我来说也像一个bug,只有当标记聚集在经度的180线附近时才会发生。 在本例中,zoomTo计算似乎不正确,只考虑了最后一个标记,因为它位于国际日期线的错误一侧 无论如何,视口上的getWidth似乎确实起作用,因此您可以修改自己的zoomTo函数,如下图所示 还要注意,在加载库时使用了kml=auto&map=js-p2d-dom——这使用了dom实现而不是canvas实现——这正确地显示了180经线两侧的标记
<!DOCTYPE HTML SYSTEM>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9" />
<style type="text/css">
html {
overflow:hidden;
}
body {
margin: 0;
padding: 0;
overflow: hidden;
width: 100%;
height: 100%;
position: absolute;
}
#mapContainer {
width:100%;
height: 100%;
left: 0;
top: 0;
position: absolute;
}
</style>
<script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.3/jsl.js?kml=auto&map=js-p2d-dom"></script>
</head>
<body>
<div id="mapContainer"></div>
<script type="text/javascript">
/* Set authentication token and appid
* WARNING: this is a demo-only key
* please register on http://api.developer.nokia.com/
* and obtain your own developer's API key
*/
nokia.Settings.set("appId", "APP_ID");
nokia.Settings.set("authenticationToken", "TOKEN");
// Get the DOM node to which we will append the map
var mapContainer = document.getElementById("mapContainer");
// Create a map inside the map container DOM node
var map = new nokia.maps.map.Display(mapContainer, {
// initial center and zoom level of the map
center: [52.51, 13.4],
zoomLevel: 13,
components: [
// We add the behavior component to allow panning / zooming of the map
new nokia.maps.map.component.Behavior()
]
});
// We create an instance of Container to store markers per city
var myContainer = new nokia.maps.map.Container();
/* We add all of the city containers to map's object collection so that
* when we add markers to them they will be rendered onto the map
*/
map.objects.add(myContainer);
// We create several of marker for a variety of famous landmarks
var firstMarker = new nokia.maps.map.StandardMarker(
[-18, 178.333],
{ text: 1 }
),
secondMarker = new nokia.maps.map.StandardMarker(
[-18.5, 180],
{ text: 2 }
),
thirdMarker = new nokia.maps.map.StandardMarker(
[-18.5, -178.333],
{ text: 3 }
);
// Add the newly created landmakers per city to its container
myContainer.objects.addAll([firstMarker, secondMarker, thirdMarker]);
/* Now we calculate the bounding boxes for every container.
* A bounding box represents a rectangular area in the geographic coordinate system.
*/
var myBoundingBox = myContainer.getBoundingBox();
zoom = 1;
map.setCenter(myBoundingBox.getCenter());
map.setZoomLevel(zoom);
while (map.getViewBounds().getWidth() > myBoundingBox.getWidth()) {
zoom++;
map.setZoomLevel(zoom);
}
zoom--
map.setZoomLevel(zoom--);
</script>
</body>
</html>
谢谢Jason,我会尝试一下,尽管使用dom而不是canvas会对移动设备的使用产生负面影响,所以我可以用它进行分类,我相信诺基亚会这样做。你知道在哪里报告一个bug吗,因为上面写着我想我发现了一个bug。我该如何报告?但实际上没有一个链接到讨论板来发布错误报告。嗨,杰森·福克斯,您的建议确实有效,但我不想接受您的回答,除非我知道问题所在画布在左右移动地图时没有正确显示标记,并且错误的zoomTo功能被添加到某个错误报告中。@user1116573最初的错误JSLA-3074是几个月前在内部提出的。目前缺少的是向公众公开这些bug报告的机制。我提出了第二个内部bug DEVPRES-10,专门用来解决这个漏洞。Jason Fox,我接受了你的答案,但我很惊讶bug需要这么长时间才能解决。有什么地方我可以订阅新的API版本发布的通知,这样我就可以在bug修复时保持我的应用程序的最新状态,比如博客,而不必记得一直查看开发者网站?Jason Fox,在zoom++之前的while循环中还需要if zoom>17{break;};来阻止它试图放大太多导致它断裂。我自己刚选了17,我想你可以放大得更远一点,而不会把它弄坏。