Is there a way to alert the user while a layer is being drawn o the screen...
I have one that is rather large and it take a second or two...I have it scale dependent so it only draws when zoomed far in but is still a bit large...I want them to know for sure that its drawn completely.
I have an image that spins but just dont know where to put the code to start and stop (show and hide) this image.
var flArchitecture = new FeatureLayer("https://server/arcgis/rest/services/Test/Resources/MapServer/1", {
mode: FeatureLayer.MODE_ONDEMAND,
infoTemplate: templateHR,
outFields: ['*']
});
app.map.addLayer(flArchitecture);
Solved! Go to Solution.
I have mine placed on the map events. This works pretty well since then I don't have to track which type of layer is currently loading. I have a loading image within my mapDiv
<img id="loadingImg" src="images/loading.gif" alt="Loading image" style="position:absolute; left:350px; top:250px; z-index:100;" />
var loading = dom.byId("loadingImg");
map.on('update-start', showLoading);
map.on('update-end', hideLoading);
function showLoading(){
domUtils.show(loading);
map.disableMapNavigation();
map.hideZoomSlider();
}
function hideLoading(error){
domUtils.hide(loading);
map.enableMapNavigation();
map.showZoomSlider();
}
You could fire an event that shows your image on update-start and then remove the image on update-end.
Hi Jay, this might work for you:
JS API 3.2 - When do layers render?
The map and the featurelayer both have this property (update-end)
featurelayer-amd | API Reference | ArcGIS API for JavaScript
I have mine placed on the map events. This works pretty well since then I don't have to track which type of layer is currently loading. I have a loading image within my mapDiv
<img id="loadingImg" src="images/loading.gif" alt="Loading image" style="position:absolute; left:350px; top:250px; z-index:100;" />
var loading = dom.byId("loadingImg");
map.on('update-start', showLoading);
map.on('update-end', hideLoading);
function showLoading(){
domUtils.show(loading);
map.disableMapNavigation();
map.hideZoomSlider();
}
function hideLoading(error){
domUtils.hide(loading);
map.enableMapNavigation();
map.showZoomSlider();
}
Thank all....
I do the below and it breaks....I comment out the 2 "app.map.on" and the image shows up but there is no control to stop it...
Is there a Require that I am missing?
UPDATE:
Tracy..I think I see it...your example
map.on('update-end' ) , hideLoading);
you had an extra ) after update-end
Working now...THANK YOU ALL FOR YOUR THOUGHTS AND HELP
Glad you figured it out. I was having some very weird behavior with my copy/paste, so I was manually trying to type out the parts that weren't right. I fixed my answer so other people will have the right syntax.
Wanted to give credit to all of you that chimed in on this post.....I thank you all very much....