salim966

refresh the map when adding new layer

Discussion created by salim966 on Nov 20, 2011
Latest reply on Nov 22, 2011 by sandallj
hi everyone,
i am quite newbie on Javascript API, what i am trying to do is:
i added new layers to the map and need to refresh or reload the map so i can see the new layer
i tried many way mentioned here but nothing works
http://forums.esri.com/Thread.asp?c=158&f=2396&t=259812

this is the error i get always.
[08:59:28.833] _547 is undefined @ http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5compact:48

here is my code for this idea

    map.removeLayer(tiledMapServiceLayer);
    map.removeLayer(dynamicMapServiceLayer);
    var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("url");
    map.addLayer(tiledMapServiceLayer);
    var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("url");
    map.addLayer(dynamicMapServiceLayer);
    map.setExtent(map.extent);

Outcomes