| MGMap.refresh |
|
void refresh()
Refreshes (redraws) the map.
If a layer is flagged for rebuild, the data will be requested from the server again before it is redrawn. Use this method after changing properties that do not invoke an automatic refresh (redraw) of the map.
This method overrides autoRefresh and always refreshes the map. Subsequent method calls adhere to the original setting of the autoRefresh flag.
This method does not work during a busy state.
Refresh does not work when called from event-handling code for onViewChanging or onMapLoaded. If you call refresh from these events, the method will fail and will set the error code to -14 (refresh disabled).
Calling refresh always sets the mouse pointer to Select mode.
Note: By default, intermediate updates of maps every 1.5 seconds during a drawing operation are enabled for all Autodesk MapGuide Viewers. This allows users to progressively see a map as it is being rendered, rather than waiting until the entire map is complete. To change this behavior, you can disable intermediate updates using the setIntermediateUpdatesEnabled method or IntermediateUpdatesEnabled property.
-1 (busy)
-14 (refresh disabled)
The following example is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It toggles the visibility of a layer called "World Countries". The refresh() method forces a map refresh, making the change immediately visible to the user:
function toggleAndRefresh()
{
var map = getMap();
var layer = map.getMapLayer("World Countries");
if (layer == null)
alert("layer not found.");
else
layer.setVisibility(!layer.getVisibility());
// force refresh to make layer change visible
map.refresh();
}
getAutoRefresh, setAutoRefresh, AutoRefresh, getIntermediateUpdatesEnabled setIntermediateUpdatesEnabled, IntermediateUpdatesEnabled