Renee,Here are the functions I've been using successfully to get around this.
dojo.require("dojo.parser");
dojo.require("dojo.cookie");
dojo.require("dijit.form.Button");
dojo.require("dijit.Toolbar");
dojo.require("esri.map");
dojo.require("esri.toolbars.navigation");
/// <summary>Variable to store the keyword for the active button.</summary>
var activeToolButton = "pan";
/// <summary>Variable to hold full extent.</summary>
var _fullExtent;
/// <summary>Variable to hold esri.Map instance.</summary>
var _map;
/// <summary>Flag to indicate whether the current extent is the first in the extent history.</summary>
var mapExtentIsFirst = false;
/// <summary>Flag to indicate whether the current extent is the last in the extent history.</summary>
var mapExtentIsLast = false;
function map_Load()
{
/// <summary>
/// Function to initialize map, run on map Load event
/// </summary>
var startExtent = new esri.geometry.Extent(minX, minY, maxX, maxY,
new esri.SpatialReference({ wkid: spatialReferenceId }));
_fullExtent = startExtent;
_map = new esri.Map(mapDivId, {
extent: startExtent,
showInfoWindowOnClick: true,
logo: false
});
// Set up the navigation toolbar.
navToolbar = new esri.toolbars.Navigation(map);
// On each map extent change, call the handler to set the active navigation tool.
dojo.connect(navToolbar, "onExtentHistoryChange", mapExtentChangeHandler);
}
function mapExtentChangeHandler()
{
// Dis/enable the Zoom Previous button based on whether the current map
// extent is first in the history.
mapExtentIsFirst = navToolbar.isFirstExtent();
jQuery('#zoomPrevious').attr('disabled', mapExtentIsFirst);
// Dis/enable the Zoom Next button based on whether the current map extent
// is last in the history.
mapExtentIsLast = navToolbar.isLastExtent();
jQuery('#zoomNext').attr('disabled', mapExtentIsLast);
// Based on the active tool button variable, set the active tool again to
// ensure the map navigation functions do not become confused.
switch (activeToolButton)
{
case "zoomin":
zoomIn();
break;
case "zoomout":
zoomOut();
break;
default:
pan();
break;
}
}
function resetMapNavTools()
{
navToolbar.deactivate();
map.disablePan();
}
// Tools - these buttons should continue to operate until the user makes
// another tool selection.
function pan()
{
resetMapNavTools();
activeToolButton = "pan";
navToolbar.activate(esri.toolbars.Navigation.PAN);
}
function zoomIn()
{
resetMapNavTools();
activeToolButton = "zoomin";
navToolbar.activate(esri.toolbars.Navigation.ZOOM_IN);
}
function zoomOut()
{
resetMapNavTools();
activeToolButton = "zoomout";
navToolbar.activate(esri.toolbars.Navigation.ZOOM_OUT);
}
// Commands - these operations should be carried out immediately but not
// change the active tool.
function zoomToFullExtent()
{
_map.setExtent(_fullExtent);
}
function zoomToNextExtent()
{
/// <summary>
/// Moves the map window to the next extent in the extent history,
/// if one exists.
/// </summary>
if (!mapExtentIsLast)
{
navToolbar.zoomToNextExtent();
}
}
function zoomToPreviousExtent()
{
/// <summary>
/// Moves the map window to the previous extent, if one exists.
/// </summary>
if (!mapExtentIsFirst)
{
navToolbar.zoomToPrevExtent();
}
}
It seems that the esri navigation toolbar doesn't quite play well with jQuery and non-digit tools (although I tried using the regular esri toolbar and it didn't work either). What eventually worked was adding the two lines in the resetMapNavTools function above:
navToolbar.deactivate();
map.disablePan();
and then calling the command to activate the desired tool. I also set the activeButton variable so I know which one to set when the extent changes and the map seems to forget the active tool.Hope that helps with your issue. Please let me know if you run into other issues.Tim