Select to view content in your preferred language

Is it possible to cancel a map navigation event?

1470
3
05-05-2011 06:46 AM
Joachim_EckboJuell
Occasional Contributor
Hi,

We are creating an application using the compact version and a cached background service, and in some cases we would like to cancel the "zoom in" event. If the user has turned on a certain layer, it should be possible to zoom in a few more levels than if this layer is not on.

I have looked at dojo stopEvent and jQuery event.preventDefault, but in the map.onZoomStart event there is no event object available to cancel. We are limiting the zoom levels using the lod property when creating the map. But it doesn't seem to be a good way of changing the lods in "run time".

Today we are checking the zoom level in the "onZoomEnd" event, and then setting a different level if the user is zoomed in too far. But thats not very elegant (extra traffic, and the map popping out looks strange).

Any ideas?
0 Kudos
3 Replies
HemingZhu
Frequent Contributor
Hi,

We are creating an application using the compact version and a cached background service, and in some cases we would like to cancel the "zoom in" event. If the user has turned on a certain layer, it should be possible to zoom in a few more levels than if this layer is not on.

I have looked at dojo stopEvent and jQuery event.preventDefault, but in the map.onZoomStart event there is no event object available to cancel. We are limiting the zoom levels using the lod property when creating the map. But it doesn't seem to be a good way of changing the lods in "run time".

Today we are checking the zoom level in the "onZoomEnd" event, and then setting a different level if the user is zoomed in too far. But thats not very elegant (extra traffic, and the map popping out looks strange).

Any ideas?


If you use navigation tool, you can use esri.toolbars.Navigation.activate(navType) and deactivate() to handle. If not, use disableMapNavigation() and enableMapNavigation(). There are a couple of things to be aware and refer JS API for more detail.
0 Kudos
Joachim_EckboJuell
Occasional Contributor
Deactivating the map navigation doesn't really solve it. The user can zoom in several zoom levels in one go using gestures, and then the map will be zoomed in too far.

So there is no way to hook into a navigation event before it happens and cancel it?
0 Kudos
HemingZhu
Frequent Contributor
Deactivating the map navigation doesn't really solve it. The user can zoom in several zoom levels in one go using gestures, and then the map will be zoomed in too far.

So there is no way to hook into a navigation event before it happens and cancel it?


map.diableMapNavigation() disallows all map navigation except the slider and pan arrows. so you mighe have to hide slider and pan arrows when you disable map navigations. By the way the map navigation is well documented on here:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/intro_navigation.htm
0 Kudos