Rightnow i'm developing an application where i have to display huge number of markers on the map roughly (30K to 50K).right now while rendering the map it is taking time to render whole points so i would like to add an loading gif icon while Navteq Map renders the pointsso that user will be aware of that map is rendering the points.
I'm using latest Nokia(Here)- Maps API version 2.5.3
.
i have tried with transitionstart
and transistionend
events but it is not showing my GIF icon but if i only handle the tranisionstart
event then the ICON willbe shown.but if i handle both events it would display the icon, i'm suspecting that it is due to start and end events are attached sidebyside.
I tried this:
JavaScript:
map = new nokia.maps.map.Display(mapContainer, {
// Initial center and zoom level of the map
center: [51.410496, 5.459197],
zoomLevel: ZoomLevel,
components: [
// We add the behavior component to allow panning / zooming of the map
new nokia.maps.map.component.Behavior(),
new nokia.maps.map.component.ZoomBar(),
new nokia.maps.map.component.Overview(),
new nokia.maps.map.component.TypeSelector(),
new nokia.maps.map.component.ScaleBar(),
infoBubbles
]
});
map.addListener("transitionstart", function () {
ChangeProgressGif(true);
});
map.addListener("transitionend", function () {
ChangeProgressGif(false);
});
function ChangeProgressGif(progressFlag)
{
if (progressFlag)
document.getElementById("ProgressIcon").style.visibility = "visible";
else
document.getElementById("ProgressIcon").style.visibility = "hidden";
}
HTML:
<img src="Images\\Resources\\LoadingGIF.gif" id="ProgressIcon"/>
NOTE: i have tried BaseMapChangeStart and BaseMapChangeEnd events also but none of them worked. any help would be greatly appreciated.
EDIT: after trying the @Jason solution it is even taking some time to render the points after the CluterProvider
state is changed to ready
.
and as mentioned in comments i tried with state Clustered
as well, but state Clustered
is coming before the ReadyState
.
Console Output from chrome:
from the console i observed that there are many ready states and can we identify which one is the last ready state so that we can stop/hide the loading icon.
Thank you.
Checking if clustering is complete
You probably want to add an observer to the
state
property of the cluster provider instead:The ClusterProvider will change state to
STATE_READY
whenever clustering is complete.Adding a loading icon
To add a "Loading" icon, you should add a custom map control like this:
It can be added to the map like this:
and styled using CSS:
You would then just need to
add()
orremove()
the html control to display the loading gif.