Problems serialize/deserialize Overlay

Topics: Help
Jun 6, 2012 at 4:45 PM

Hi radioman,

first of all
             -Many thanks for your work on this great control!!!!

Im am trying so save an GMapOverlay to a file and later load it again into the MapControl. Here is what i do:

With SaveFileDialog
	If .ShowDialog() = DialogResult.OK Then
		Using fs As Stream = File.Open(.FileName, FileMode.Create)
			Dim bf As New BinaryFormatter
			bf.Serialize(fs, m_PointsOverlay)
		End Using
	End If
End With

Dim overlay As GMap.NET.WindowsForms.GMapOverlay
	Using fs As Stream = File.Open(filename, FileMode.Open, FileAccess.Read)
		Dim bf As New BinaryFormatter
		overlay = bf.Deserialize(fs)
	End Using
Catch ex As Exception
End Try
If I try to add this overlay to MainMap I get a red cross thru the hole control.
What am I doing wrong?


Jun 6, 2012 at 4:58 PM
Edited Jun 6, 2012 at 4:58 PM

I tried it direct in your demo, and this is where it crashed:

 public override void OnRender(Graphics g)
 from GMapRoundedToolTip

Marker is Null here?

In the overlay the is only one Marker with a text in the tooltip.

Any suggestions?

Jun 6, 2012 at 5:02 PM

nop, need some debugging..

Jun 6, 2012 at 5:12 PM

If I replace the tooltip from the marker with a new one, before adding it to MainMap everything works. But I need to do the following:

For Each m As markers.GMarkerGoogle In PointsOverlay.Markers

	Dim tttext As String = m.ToolTipText
	Dim ttmode As MarkerTooltipMode = m.ToolTipMode
	Dim tt As New GMapToolTip(m)
	m.ToolTip = tt
	m.ToolTipMode = ttmode
	m.ToolTipText = tttext

If I need to create a tooltip with the marker in the constructor, why must I set the markers ToolTip Property to the new ToolTip? May this be the Problem?

Jun 6, 2012 at 5:23 PM
Edited Jun 6, 2012 at 5:23 PM

Hm, if I add this

      	if(this.ToolTip != null)
      		this.ToolTip.Marker = this;

protected GMapMarker(SerializationInfo info, StreamingContext context)

in GMapMarker.cs, everything is working!


Jun 6, 2012 at 6:00 PM

thanks, i'll fix this

Jun 6, 2012 at 6:04 PM

Fine! Maybe a


marker.ToolTip = this;

in the constructor of GMapToolTip makes also sense?