Select to view content in your preferred language

progress while loading feature layer.

1355
7
Jump to solution
07-29-2014 11:32 AM
jaykapalczynski
Honored Contributor

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);

0 Kudos
1 Solution

Accepted Solutions
TracySchloss
Honored Contributor

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();

  }

View solution in original post

0 Kudos
7 Replies
TimWitt2
MVP Alum

You could fire an event that shows your image on update-start and then remove the image on update-end.

0 Kudos
KevinDeege
Esri Contributor

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

0 Kudos
TracySchloss
Honored Contributor

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();

  }

0 Kudos
jaykapalczynski
Honored Contributor

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:

0 Kudos
jaykapalczynski
Honored Contributor

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

0 Kudos
TracySchloss
Honored Contributor

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.

0 Kudos
jaykapalczynski
Honored Contributor

Wanted to give credit to all of you that chimed in on this post.....I thank you all very much....

0 Kudos