MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
Hi everybody...I want to share a code on which i was working for many days and at the end i got it.... It saves the map state and we donot have to again and again add several layers.I posted here so that any one who need it can use.Firstly i have written a code to add all the layers one by o
code to save the map state
Posted by: preetisingh ()
Date: May 08, 2012 02:04AM

Hi everybody...I want to share a code on which i was working for many days and at the end i got it....
It saves the map state and we donot have to again and again add several layers.I posted here so that any one who need it can use.Firstly i have written a code to add all the layers one by one(that code i have not shown here) then by using the save button i have saved it in the file named map_state.Then when the next time we want to add the map we donot have to add all the layers one by one just click on the RestoreMap button and the saved map is loaded.We just have to create the file map_state manually in c drive.The coding is done in vb6.
I have a problem here that i could load the map but the enteries(Layers name) which are in the legend can't be restored.Can anybody tell me how to restore the legend enteries....

Dim filename as string
Dim filepath(50) as string

Private Sub btnRestoreMap_Click()
Dim strText as string
Dim res as boolean
strText=GetFileContent("C:\map_state.txt")
res=Map1.DeserializeMapState(strText,True,filename)
End Sub

Function GetFileContent(Name as string) as string
Dim intUnit as integer
On ErrorGoto ErrGetFileContent
intUnit=Freefile
Open Name For Input as intUint
GetFileContent=Input(LOF(intUint),intUnit)
ErrGetFileContent:
Close intUnit
Exit Function
End Function

Private Sub save_Click()
Dim fileLoc as string
filename1=C:\map_state.txt"
filename1=Map1.SreializeMapState(True,filename)
fileLoc="C:\map_state.txt"
dim fs as FileSystemObject
Dim ts as TextStream
Set fs = New FileSystemObject
Set ts=fs.OpenTextFile("C:\map_state.txt",ForWriting,True)
ts.Write(filename1)
ts.close
set ts=Nothing
set fs=Nothing
Map1.RemoveAllLayers
End Sub

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: