MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
I want to save the state of the map and for that i have written the following coding.but when i open the map again it is not visible.Please tell where i am wrong.It is saving the map state in the file "C:\map_state.shp" as when i open it in notepad it shows the mapstate. Im
map not visible after saving...Please help it's urgent
Posted by:
preetisingh ()
Date: April 18, 2012 09:33AM
I want to save the state of the map and for that i have written the following coding.but when i open the map again it is not visible.Please tell where i am wrong.It is saving the map state in the file "C:\map_state.shp" as when i open it in notepad it shows the mapstate.
Imports Microsoft.VisualBasic.FileIO
Imports System.IO.File
Imports System.IO.StreamWriter
Public Class Form1
Inherits System.Windows.Forms.Form
Dim oWrite As System.IO.StreamWriter = System.IO.File.CreateText("C:\sample.txt")
Dim filename As String
Dim filename1 As String = New String("C:\map_state.shp")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim theFile As String
Dim dlgopen As New OpenFileDialog
Dim mySF As New MapWinGIS.Shapefile
dlgopen.Filter = "Only Show Shapefiles |*.shp"
dlgopen.ShowDialog()
theFile = dlgopen.FileName
mySF.Open(theFile)
Dim newhandle As Integer = Map.AddLayer(mySF, True)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Map.SendMouseDown = True
Map.SendMouseMove = True
Map.SendMouseUp = True
Map.SendSelectBoxFinal = True
End Sub
Private Sub btnSerialize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSerialize.Click
Dim res As Boolean = Map.SaveMapState(filename1, True, True)
oWrite.Write(filename1)
End Sub
Private Sub btnDeserialize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeserialize.Click
Dim res As Boolean = Map.LoadMapState(filename1, Null)
End Sub
End Class
Imports Microsoft.VisualBasic.FileIO
Imports System.IO.File
Imports System.IO.StreamWriter
Public Class Form1
Inherits System.Windows.Forms.Form
Dim oWrite As System.IO.StreamWriter = System.IO.File.CreateText("C:\sample.txt")
Dim filename As String
Dim filename1 As String = New String("C:\map_state.shp")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim theFile As String
Dim dlgopen As New OpenFileDialog
Dim mySF As New MapWinGIS.Shapefile
dlgopen.Filter = "Only Show Shapefiles |*.shp"
dlgopen.ShowDialog()
theFile = dlgopen.FileName
mySF.Open(theFile)
Dim newhandle As Integer = Map.AddLayer(mySF, True)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Map.SendMouseDown = True
Map.SendMouseMove = True
Map.SendMouseUp = True
Map.SendSelectBoxFinal = True
End Sub
Private Sub btnSerialize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSerialize.Click
Dim res As Boolean = Map.SaveMapState(filename1, True, True)
oWrite.Write(filename1)
End Sub
Private Sub btnDeserialize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeserialize.Click
Dim res As Boolean = Map.LoadMapState(filename1, Null)
End Sub
End Class
Re: map not visible after saving...Please help it's urgent
Posted by:
sindizzy ()
Date: April 18, 2012 12:44PM
Please dont double post. If you want your first post to have more visibility then bump it by requesting an update. But be calm about it. As I stated in your other post (see now if someone posts a solution it will not be seen in your other post which is exactly the same question) have you taken a look at the documentation to see how to properly save a map state? A map state I belive is more like XML which is not a shapefile as you are saving it.
[mapwingis.codeplex.com]
AGP
[mapwingis.codeplex.com]
AGP
Sorry, only registered users may post in this forum.


