Select to view content in your preferred language

Hide cached service and zoom to any scale problem

2383
5
12-14-2010 02:22 AM
MarkSmith
Occasional Contributor
Hello,

I have a need to zoom to any scale on a dynamic service.  I have 2 services in my JavaScript API, a cached service for background maps and a dynamic service for layers.  By default the zoom scales are defined from the cached service, but I need the user to be able to switch off the cached maps and then zoom to a precise extent unrestricted by the cached service scales.

Essentially I want to be able to hide/remove the cached service and the restrictions imposed by the cached scales, and allow the user to zoom to any given scale on just the dynamic service.

I can remove the cached service using map.removeLayer(myMapServiceLayer); and hide the zoom slider, but the API continues to remember the cached scales and will not allow the user to zoom to an accurate extent, even though they are now only viewing the dynamic service.

Can anyone please offer a method that will hide/remove the cached service and so disable the scale-snapping effect and allow the user to zoom to exactly whatever scale they wish?  I also need to add the cached service back in again, but one thing at a time.

Thank you, Mark.
0 Kudos
5 Replies
timgogl
Deactivated User
i needed to do something similar to this, i sat down and talked it over with my gis guy, and between the two of us, we figured out that we could make a 'fake' service that would scale down to a very close scale, as long as that is the first service loaded, we could zoom into and beyond the services we were using in our interface.


hrm.. after re-reading this.... i hope it makes sense.
0 Kudos
OctavianIercan
New Contributor
One way to handle this is:
You could create a cached service, cache it till let's say level 11. Delete all cached images from the last level (in this case level 11). Somehow arcgisserver starts loading the dynamic data if you zoom to level 11 or lower. You could switch off all the data using the scales in your mxd or display the dynamic non cached data.

This worked at least until arcgis server 9.3.1 (not sure about 10)
0 Kudos
MarkSmith
Occasional Contributor
Thanks for the replies so far, interesting, but I don't think they help me.  Imagine my API uses 2 services, a dynamic service with my layers, and a cached service cached at scales 1:50,000, 1:25,000, 1:10,000 and 1:2,500 for example.  I want to be able to remove/hide the cached service and zoom to any scale on the dynamic service, for example 1:38,536.  My problem isn't one of just wanting to zoom in further than the cahced scales allow, I need to zoom to any scale by removing/hiding the cached service and so stopping the snap-to-scale that happens when using a cached service.

Thank you.

Mark.
0 Kudos
HemingZhu
Frequent Contributor
use map.destroy() to destroy the map instance when you remove the tiled layer. After the map is destroyed. it is no longer valid,  however you can re-use the div element of the map to create a new map instance.


Thanks for the replies so far, interesting, but I don't think they help me.  Imagine my API uses 2 services, a dynamic service with my layers, and a cached service cached at scales 1:50,000, 1:25,000, 1:10,000 and 1:2,500 for example.  I want to be able to remove/hide the cached service and zoom to any scale on the dynamic service, for example 1:38,536.  My problem isn't one of just wanting to zoom in further than the cahced scales allow, I need to zoom to any scale by removing/hiding the cached service and so stopping the snap-to-scale that happens when using a cached service.

Thank you.

Mark.
0 Kudos
MarkSmith
Occasional Contributor
Hi,
Yes that'll work.  It means doing a bit of work getting and re-applying graphics and extent since all the services in the map get destroyed, but I can handle that, so thanks very much for the advice.
Mark.
0 Kudos