Select to view content in your preferred language

Error on Removing all map layers

790
2
Jump to solution
02-14-2013 12:08 PM
JamesVillanueva
Regular Contributor
I am seeing the following error:

TypeError: this.map.getLayer(...) is undefined
https://<Machine Name>/arcgis-js/3.3/js/esri/dijit/Scalebar.js
Line 19

When I remove all layers from the map and add new layers. Is this expected behavior? If so, has anyone found a work around. The only thing solving it for me is to add a layer to map, OSM, as invisible and never removing it. This is not a good solution for me as I may be in an environment with no outside internet access where I am simply using graphics layers within the map. Can this be done with a graphics layer to satisfy the map and get around this error?
0 Kudos
1 Solution

Accepted Solutions
StephenLead
Honored Contributor
Hi James,

Are you able to share your code or link to a live example? This will make it a lot easier to debug.

Prior to the 3.3 release of the JS API it wasn't possible to remove the basemap layer, but this is now possible:

Use a graphics layer or a feature layer as the only layer in a map
The map no longer requires a tiled or dynamic service to be the first type of layer added to the map. View the new Feature Layer in any projection sample or thegas prices by state example to see this in action.


Are you using v3.3?

Steve

View solution in original post

0 Kudos
2 Replies
StephenLead
Honored Contributor
Hi James,

Are you able to share your code or link to a live example? This will make it a lot easier to debug.

Prior to the 3.3 release of the JS API it wasn't possible to remove the basemap layer, but this is now possible:

Use a graphics layer or a feature layer as the only layer in a map
The map no longer requires a tiled or dynamic service to be the first type of layer added to the map. View the new Feature Layer in any projection sample or thegas prices by state example to see this in action.


Are you using v3.3?

Steve
0 Kudos
JamesVillanueva
Regular Contributor
My code is too large to post. I changed the way I was dealing with the base layers. I just ensured I added the new one before I removed the old one, and everything appears to be working. Thanks for the tips.
0 Kudos