Map not loaded after other form with ShowDialog

Topics: General
Dec 13, 2011 at 10:03 AM

Hi,
this is my situation:
- a form with the GMapControl;
- before to load the map (setting MapProvider property) I visualize a simple system.windows.form with showdialog command, then I close and dispose this form.

Problem: everything works fine, but the map is loaded only in the top-left corner of the GMapControl.

Can anyone help me?

Thanks,

Gabeluna

 

Coordinator
Dec 13, 2011 at 10:25 AM

set dock = fill or something

Dec 13, 2011 at 10:35 AM

I set myGMapControl.dock = DockStyle.Fill from designer and also beetwen myform.showdialog and myGMapControl.currentProvider = GMap.NET.MapProviders.GMapProviders.BingMap,

but nothing change, I always have the error...

Coordinator
Dec 13, 2011 at 10:43 AM

does it changes when you resize the form?

Dec 13, 2011 at 12:07 PM

Yes after the resize, it's ok...

What code must I write?

Coordinator
Dec 13, 2011 at 12:41 PM

i don't see you code, do you manually add map to form?

Dec 13, 2011 at 12:56 PM

Yes, from VS2010 toolbox

My code:

 Dim myForm As New CustomForm
 If myForm.ShowDialog = Windows.Forms.DialogResult.OK Then
   ' Do this
 Else
   ' Do that
 End If

If myForm Is Nothing = False Then
   myForm.Dispose()
   myForm = Nothing
End If

Me.cntMainMap.Manager.Mode = GMap.NET.AccessMode.ServerAndCache
Me.cntMainMap.MapProvider = _mappaProviderCorrente

Me.cntMainMap.MinZoom = Globals.ZoomMin
Me.cntMainMap.MaxZoom = Globals.ZoomMax
Me.cntMainMap.Zoom = Globale.ZoomDefault
Me.cntMainMap.MapProvider.Language = GMap.NET.LanguageType.Italian.ToString

Me.cntMainMap.CanDragMap = True

Me.cntMainMap.DragButton = Windows.Forms.MouseButtons.Left

_mappaOverlayRoute = New GMap.NET.WindowsForms.GMapOverlay(Me.cntMainMap, "OverlayRoute")
Me.cntMainMap.Overlays.Add(_mappaOverlayRoute)
_mappaOverlayMarker = New GMap.NET.WindowsForms.GMapOverlay(Me.cntMainMap, "OverlayMarker")
Me.cntMainMap.Overlays.Add(_mappaOverlayMarker)
_mappaOverlayMarkerSelection = New GMap.NET.WindowsForms.GMapOverlay(Me.cntMainMap, "OverlayMarkerSelection")
Me.cntMainMap.Overlays.Add(_mappaOverlayMarkerSelection)

Me.cntMainMap.SetCurrentPositionByKeywords("Italy, Roma")
Coordinator
Dec 13, 2011 at 1:02 PM

set these before map is loaded:

Me.cntMainMap.Manager.Mode = GMap.NET.AccessMode.ServerAndCache
Me.cntMainMap.MapProvider = _mappaProviderCorrente
Me.cntMainMap.MinZoom = Globals.ZoomMin
Me.cntMainMap.MaxZoom = Globals.ZoomMax
Me.cntMainMap.Zoom = Globale.ZoomDefault

Dec 13, 2011 at 1:34 PM

In this case I partially resolve my problem, because I show my form after the main form load and everything works, but if I  put my form before the commands you suggest in previous replay, I have the same problem...

 This is OK:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

Me.cntMainMap.Manager.Mode = GMap.NET.AccessMode.ServerAndCache
Me.cntMainMap.MapProvider = _mappaProviderCorrente
Me.cntMainMap.MinZoom = Globals.ZoomMin
Me.cntMainMap.MaxZoom = Globals.ZoomMax
Me.cntMainMap.Zoom = Globale.ZoomDefault

MyBase.OnLoad(e)

myForm.ShowDialog

end Sub

 

But this doesn'work:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

myForm.ShowDialog

Me.cntMainMap.Manager.Mode = GMap.NET.AccessMode.ServerAndCache
Me.cntMainMap.MapProvider = _mappaProviderCorrente
Me.cntMainMap.MinZoom = Globals.ZoomMin
Me.cntMainMap.MaxZoom = Globals.ZoomMax
Me.cntMainMap.Zoom = Globale.ZoomDefault

MyBase.OnLoad(e)

end Sub


 

Coordinator
Dec 13, 2011 at 2:27 PM

onLoad is too late, use constructor

Dec 13, 2011 at 3:28 PM

How can i do that?

Coordinator
Dec 13, 2011 at 5:05 PM

...

Dec 14, 2011 at 12:01 PM

I solved,

thanks