Here's the procedure that we used to close, reopen and add the WMS layer back to the map window:
SUB CloseAndReopen(ByVal strWMSLayerName as STRING, ByVal intFrontWinID AS INTEGER)
'this is one of the last steps!
'need to:
'1. find the layer order
'2. close the layer
'3. reopen & add to window
Dim intLayerPos as integer
Dim intLayerCount as integer
Dim intCounter as integer
Dim tagFoundLayer as Logical
Dim strFullTABFile as String
Dim fltMapCentreX as Float
Dim fltMapCentreY as Float
Dim fltMapZoom as Float
Set Event Processing Off
If gtagDebug = TRUE Then
Print "Set Event Processing Off"
End If
intLayerCount = MapperInfo(intFrontWinID, MAPPER_INFO_LAYERS)
strFullTABFile = TableInfo(strWMSLayerName, TAB_INFO_TABFILE)
fltMapCentreX = MapperInfo(intFrontWinID, MAPPER_INFO_CENTERX)
fltMapCentreY = MapperInfo(intFrontWinID, MAPPER_INFO_CENTERY)
fltMapZoom = MapperInfo(intFrontWinID, MAPPER_INFO_Zoom)
tagFoundLayer = False
For intCounter = 1 to intLayercount
If LayerInfo(intFrontWinID, intCounter, LAYER_INFO_NAME) = strWMSLayerName Then
intLayerPos = intCounter
tagFoundLayer = True
If gtagDebug = TRUE Then
Print "Found LayerInfo match!"
Print "intLayerPos: " + str$(intLayerPos)
End If
Else
If gtagDebug = TRUE Then
Print "Check for match: " + LayerInfo(intFrontWinID, intCounter, LAYER_INFO_NAME) + " : " + strWMSLayerName
End If
End If
Next
If tagFoundLayer = True then
If gtagDebug = TRUE Then
Print "Close & Reopen"
End If
'proceed to close & reopen
Close Table strWMSLayerName
Open Table strFullTABFile
Add Map Window intFrontWinID Layer strWMSLayername Position intLayerPos
'now reset mapper stuff
Set Map Window intFrontWinID Center (fltMapCentreX, fltMapCentreY) Zoom fltMapZoom
Else
If gtagDebug = TRUE Then
Print "Don't close - no match found for layername"
End If
End If
If gtagDebug = TRUE Then
Print "Set Event Processing On"
End If
Set Event Processing On
END SUB
Note that this also works for one map window. If they user has the WMS table in multiple map window, you need to extend this to meet those requirements
Peter Horsbøll Møller
Pitney Bowes Software