gpt4 book ai didi

javascript - 在此处的 map 2.5.3 上渲染时,标记突然丢失

转载 作者:行者123 更新时间:2023-11-28 19:55:50 25 4
gpt4 key购买 nike

我开发了一个应用程序,它可以在 navteq map 上显示标记集合。当我使用 navteq map 2.2.3 时,一切工作正常,但作为 Navteq map 2.2。 3 不支持异步行为 我已切换到支持异步 行为的HereMaps 2.5.3

现在切换到最新版本后我面临一个奇怪的问题。也就是说,在渲染 map 上的标记时,突然已经渲染的点/标记(某些点)消失了。这个问题会发生几次,如果我再次尝试在 map 上生成标记,它会正常工作。

所以我认为我需要在渲染之前正确处理一些显示事件。

示例图片如下:

图像 1:正确渲染的标记

Properly Rendered Markers

图像 2:已渲染但缺少一些点

enter image description here

MyCode如下:

下面的函数负责在 map 上显示标记。

function displayAllPoints(arrLightPointCoordinats, totalLightPoints, selectedSegmentId,
totalSegmentsCount, segmentColorcode)
{
var MyTheme1 = function () {
};
segmentColorcode = segmentColorcode.substring(2, segmentColorcode.length - 1);
MyTheme1.prototype.getNoisePresentation = function (dataPoint) {
var markerLightPoint = new nokia.maps.map.Marker(dataPoint, {
icon: new nokia.maps.gfx.BitmapImage("..//Images//Lightpoint//" + segmentColorcode + ".png"),
anchor: {
x: 12,
y: 12
}
});
return markerLightPoint;
};
MyTheme1.prototype.getClusterPresentation = function (data) {
var markerLightPoint = new nokia.maps.map.StandardMarker(data.getBounds().getCenter(), {
icon: new nokia.maps.gfx.BitmapImage("..//Images//SegmentController/" +
segmentColorcode + ".png", null, 66, 65),
text: data.getSize(),
zIndex: 2,
anchor: {
x: 12,
y: 12
}
});
return markerLightPoint;
};
var indexes = new nokia.maps.clustering.Index();
var lightpointsDataSet1 = new Array();

for (var i = 0; i < totalLightPoints; i++) {
lightpointsDataSet1[i] = { latitude: arrLightPointCoordinats[i][0],
longitude: arrLightPointCoordinats[i][1], title: 'LightPoint ' + (i + 1) };
indexes.add([arrLightPointCoordinats[i][0], arrLightPointCoordinats[i][1]]);
}
var ClusterProvider = nokia.maps.clustering.ClusterProvider,
theme = new MyTheme1(),
clusterProvider = new ClusterProvider(map, {
eps: 0.00000000001,
minPts: 1000000,
strategy: nokia.maps.clustering.ClusterProvider.STRATEGY_DENSITY_BASED,
index: indexes,
theme: theme,
dataPoints: []
});
clusterProvider.addAll(lightpointsDataSet1);
clusterProvider.cluster();
map.update(-1, 0);
//set zoom level here

setCenterAndZoom(13, arrSegmentControllerIds[0]);
}

任何帮助将不胜感激。

最佳答案

在启动集群之前,我使用显示就绪事件:

        map.addListener("displayready", function()
{
mapContainer.style.display = 'block';

// load the photos as cluster data
url = "http://developer.here.com/apiexplorer/examples/res/clustering/photos.js";
script = document.createElement("script");
script.src = url;
document.body.appendChild(script);
});

onDataReceive = function(data)
{
displayAllPoints(data);
}

function displayAllPoints(arrLightPointCoordinates)
{ {
var MyTheme1 = function (){};
MyTheme1.prototype.getNoisePresentation = function (dataPoint) {
var markerLightPoint = new nokia.maps.map.Marker(dataPoint, {
icon: new nokia.maps.gfx.BitmapImage("/res/marker_red.png"),
anchor: {
x: 12,
y: 12
}
});
return markerLightPoint;
};

MyTheme1.prototype.getClusterPresentation = function (data) {
var markerLightPoint = new nokia.maps.map.StandardMarker(data.getBounds().getCenter(), {
icon: new nokia.maps.gfx.BitmapImage("/res/marker_green.png", null, 66, 65),
text: data.getSize(),
zIndex: 2,
anchor: {
x: 12,
y: 12
}
});
return markerLightPoint;
};
/*
var indexes = new nokia.maps.clustering.Index();
var lightpointsDataSet1 = new Array();

for (var i = 0; i < totalLightPoints; i++) {
lightpointsDataSet1[i] = { latitude: arrLightPointCoordinats[i][0],
longitude: arrLightPointCoordinats[i][1], title: 'LightPoint ' + (i + 1) };
indexes.add([arrLightPointCoordinats[i][0], arrLightPointCoordinats[i][1]]);
}
*/
var ClusterProvider = nokia.maps.clustering.ClusterProvider,
theme = new MyTheme1(),
clusterProvider = new ClusterProvider(map, {
eps: 0.00000000001,
minPts: 1000000,
strategy: nokia.maps.clustering.ClusterProvider.STRATEGY_DENSITY_BASED,
// index: indexes,
theme: theme,
dataPoints: []
});
clusterProvider.addAll(arrLightPointCoordinates);
clusterProvider.cluster();
map.update(-1, 0);
//set zoom level here
// setCenterAndZoom(13, arrSegmentControllerIds[0]);
}

希望有帮助。您还可以查看最新版本 2.5.4。

最好,

多姆

关于javascript - 在此处的 map 2.5.3 上渲染时,标记突然丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22592829/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com