+ Reply to Thread
Results 1 to 6 of 6

Thread: Map.onLayersAddResult only fires if use Map.addLayers

  1. #1
    Bryan Baker
    Join Date
    May 2010
    Posts
    38
    Points
    7
    Answers Provided
    1


    1

    Default Map.onLayersAddResult only fires if use Map.addLayers

    It seems that the Map's onLayersAddResult gets fired only if you've added layers to the map using addLayers. The function I've set for onLayersAddResult does not get called if I add layers one at a time with the addLayer method. If this is by design, the documentation for onLayersAddResult should say that it only works for layers added with addLayers.

  2. #2
    Paul Angelino
    Join Date
    Mar 2011
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: Map.onLayersAddResult only fires if use Map.addLayers

    Indeed, glad I stumbled on your post! I was struggling to figure out why the heck the onLayersAddResult event was not firing in my app. This should definitely be documented better. It is entirely unobviously that it would behave this way, and I would have been stuck on this much longer had I not seen this post.

  3. #3
    Derek Swingley

    Join Date
    May 2010
    Posts
    1,859
    Points
    892
    Answers Provided
    165


    0

    Default Re: Map.onLayersAddResult only fires if use Map.addLayers

    I would say that this is documented, but could probably be improved. If you look at the documentation for map.addLayers(), it says:
    The onLayerAddResult event fires for each layer that is added. Once all the layers are added to the map the onLayersAddResult fires.
    But the documentation for map.addLayer() makes no mention of firing the onLayersAddResult.
    --
    @derekswingley | ArcGIS API for JavaScript Team Member.

    If you're posting a code or html sample, please wrap it in code tags.

  4. #4
    Bryan Baker
    Join Date
    May 2010
    Posts
    38
    Points
    7
    Answers Provided
    1


    1

    Default Re: Map.onLayersAddResult only fires if use Map.addLayers

    Quote Originally Posted by swingley View Post
    I would say that this is documented, but could probably be improved. If you look at the documentation for map.addLayers(), it says:


    But the documentation for map.addLayer() makes no mention of firing the onLayersAddResult.
    Well, I used to write documentation at ESRI, and I would say that the mention of it in addLayers doesn't really qualify as helpful. The doc for onLayersAddResult simply says:

    "Fires after all layers are added to the map. (As of v2.0)"

    It doesn't say it only fires after you call one specific method and not any others, just that it fires after all layers are added. That two of us took the trouble to write about this suggests that the documentation should be clearer.

  5. #5
    Kelly Hutchins

    Join Date
    Oct 2009
    Posts
    885
    Points
    622
    Answers Provided
    106


    0

    Default Re: Map.onLayersAddResult only fires if use Map.addLayers

    Thanks everyone for pointing out this deficiency in the documentation. It definitely could be clearer and we'll get it updated soon.

  6. #6
    Mohmmad Bhat
    Join Date
    Oct 2012
    Posts
    2
    Points
    1
    Answers Provided
    0


    1

    Default Re: Map.onLayersAddResult only fires if use Map.addLayers

    Please use the following syntax while adding the layer on the map. The method will definitely be fired.
    map.addLayers([operational]);

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts