问题
I have developed an application where it displays collection of markeres on the navteq map.when i was working with navteq maps 2.2.3
everything was working fine, but as Navteq maps 2.2.3
does not support for Asynchronous behaviour
i have switched to HereMaps 2.5.3
which supports Asynchronous
behaviour.
Now after switching to latest version i'm facing one strange problem. that is while rendering the markers on the map suddenly already rendered points/markers(some points) gets disappeared.this problem happens some times and if again i try to generate markeres on the map it works fine.
so i think i need to handle some Display events properly before rendering.
sample images are as below:
Image 1: Properly Rendered markers

Image 2: Rendered but missing some points

MyCode is as below:
the below function is responsible for displaying the markers on the 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]);
}
Any help would be greatly appreciated.
回答1:
I use the Display Ready Event, before starting the Clustering:
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]);
}
Hope that helps. Also you can check out the newest version 2.5.4.
Best,
Dom
来源:https://stackoverflow.com/questions/22592829/markers-are-missing-suddenly-while-rendering-on-here-maps-2-5-3