Gmap Marker in VB.net

Topics: Windows Forms
Mar 28, 2011 at 3:29 PM

hi,

i am not able to set an marker in the map under Vb.net. Sorry about my bad english.

My Code:

Private

 

 Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

Button2.Click

GMapControl1.MarkersEnabled =

True

 Dim mark3 As New GMapMarkerGoogleGreen

(GMapControl1.FromLocalToLatLng(xachs, yachs))

 

 

 

 

 

Dim pos As

Double

 

mark3.IsVisible =

True

mark3.DisableRegionCheck =

True

GMapControl1.UpdateMarkerLocalPosition(mark3)

pos = mark3.Position.Lat

mark3.Offset =

New System.Drawing.Point

(xachs, yachs)

GMapControl1.Overlays.Add(mark3.Overlay)

 

End

Sub

 

 
Mar 28, 2011 at 8:32 PM

you do it from the wrong end, first add overlay only once at startup and add marker to it, then in mouse event Marker.Position = MainMap.FromLocalToLatLng(e.X, e.Y);

Mar 29, 2011 at 9:41 AM

Hi Radioman,

i have tried this:

Imports GMap.NET

Imports System

Imports System.Drawing

Imports System.Drawing.Drawing2D

Imports System.Runtime.Serialization

Imports GMap.NET.WindowsForms.Markers

Imports System.IO

Public Class Form1

Public marker As New GMapMarkerGoogleGreen(GMapControl1.fromlocaltolatlng(10, 10))

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.GMapControl1.MapType = MapType.GoogleMap

Me.GMapControl1.MinZoom = 1

Me.GMapControl1.MaxZoom = 17

Me.GMapControl1.Zoom = 17

Me.GMapControl1.SetCurrentPositionByKeywords("St.Blasien")

Me.GMapControl1.Zoom = 17

End Sub

Private Sub GMapControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.MouseDown

marker.Position = GMapControl1.FromLocalToLatLng(e.X, e.Y)

End Sub

End Class

But i get an Error: (German “Quellverweis fehlt”)

System.InvalidOperationException wurde nicht behandelt.

Message=Fehler beim Erstellen des Formulars. Weitere Informationen finden Sie in Exception.InnerException. Fehler: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt..

Source=GmapTest2

StackTrace:

bei GmapTest2.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 190.

bei GmapTest2.My.MyProject.MyForms.get_Form1()

bei GmapTest2.My.MyApplication.OnCreateMainForm() in C:\Users\7735Z\AppData\Local\Temporary Projects\GmapTest2\My Project\Application.Designer.vb:Zeile 35.

bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()

bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()

bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)

bei GmapTest2.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81.

bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)

bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

bei System.Threading.ThreadHelper.ThreadStart()

InnerException: System.NullReferenceException

Message=Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.

Source=GmapTest2

StackTrace:

bei GmapTest2.Form1..ctor() in C:\Users\7735Z\AppData\Local\Temporary Projects\GmapTest2\Form1.vb:Zeile 10.

InnerException:

I think i am stupid…..

Thanks for your help.

My testprojekt is in the Rar-File

Please help !!!

Von: radioman [email removed]
Gesendet: Montag, 28. März 2011 21:33
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

you do it from the wrong end, first add overlay only once at startup and add marker to it, then in mouse event Marker.Position = MainMap.FromLocalToLatLng(e.X, e.Y);

Mar 29, 2011 at 10:24 AM

don't use GMapControl1.fromlocaltolatlng(10, 10) if you cant see the map

Mar 29, 2011 at 10:42 AM

OK… i tried this

Imports GMap.NET

Imports System

Imports System.Drawing

Imports System.Drawing.Drawing2D

Imports System.Runtime.Serialization

Imports GMap.NET.WindowsForms.Markers

Imports System.IO

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.GMapControl1.MapType = MapType.GoogleMap

Me.GMapControl1.MinZoom = 1

Me.GMapControl1.MaxZoom = 17

Me.GMapControl1.Zoom = 17

Me.GMapControl1.SetCurrentPositionByKeywords("St.Blasien")

Me.GMapControl1.Zoom = 17

End Sub

Private Sub GMapControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.MouseDown

Dim marker As New GMapMarkerGoogleGreen(GMapControl1.FromLocalToLatLng(e.X, e.Y))

GMapControl1.Overlays.Add(marker.Overlay)

marker.Position = GMapControl1.FromLocalToLatLng(e.X, e.Y)

End Sub

End Class

I get an Error anyway…

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 11:24
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

don't use GMapControl1.fromlocaltolatlng(10, 10) if you cant see the map

Mar 29, 2011 at 11:50 AM

add overlay only once at load event

Mar 29, 2011 at 12:10 PM

But if i make the Dim marker as new GmapMarkerGoogleGreen in the load-Event, I don’t have the variable in the mouse event…. Cant you give me just an expamle…. Please !?

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 12:51
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

add overlay only once at load event

Mar 29, 2011 at 1:26 PM

just study  the demos ;}

Mar 29, 2011 at 1:40 PM

I cant find the demos…. Always a error on the server… sorry… do you have an link for an

Demo in Visual Basic 2008 or 2010 ??

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 14:27
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

just study the demos ;}

Mar 29, 2011 at 1:46 PM

what do you mean 'error on server'?

Mar 29, 2011 at 1:53 PM

If i search in google

http://www.google.de/search?hl=de&source=hp&q=visual+basic+%2B+gmap&aq=f&aqi=&aql=&oq=

then i get an link for vb.net on your page… but if I click on it… there is an Error… (Hardcopy)

Error on this Link (for Example):

http://greatmaps.codeplex.com/Thread/View.aspx?ThreadId=81062&ANCHOR

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 14:46
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

what do you mean 'error on server'?

Mar 29, 2011 at 2:03 PM

downlaod source http://greatmaps.codeplex.com/SourceControl/list/changesets it's c# but it's exactly the same in vb.net/c++.net

Mar 29, 2011 at 2:42 PM

Sorry… i dont really understand c++….. and nobody in the world can explain it in VB 2008…

In every Fourm I have looked, nobody have created an marker… I just want an marker on a position… nothing else …

But it seems very difficult…

Thank you for your help…

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 15:03
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

downlaod source http://greatmaps.codeplex.com/SourceControl/list/changesets it's c# but it's exactly the same in vb.net/c++.net

Mar 29, 2011 at 3:08 PM

Hi again…. :-)

Sorry, but isn’t it possible … just a little example.. very short…

How to add an marker in Visual basic 2010…. please

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 15:03
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

downlaod source http://greatmaps.codeplex.com/SourceControl/list/changesets it's c# but it's exactly the same in vb.net/c++.net

Mar 29, 2011 at 3:09 PM

He have the same problem,

But the solution isn’t there….

http://greatmaps.codeplex.com/discussions/251274

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 15:03
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

downlaod source http://greatmaps.codeplex.com/SourceControl/list/changesets it's c# but it's exactly the same in vb.net/c++.net

Mar 29, 2011 at 4:36 PM

Hi again… i have it…. Thank you

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 15:03
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

downlaod source http://greatmaps.codeplex.com/SourceControl/list/changesets it's c# but it's exactly the same in vb.net/c++.net

Mar 29, 2011 at 10:23 PM

;}

Mar 30, 2011 at 10:52 AM

Hi Radioman,

i am again….. is it possibel with Gmap.Net to make a rote like the JPG in the attachement ?

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 15:03
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

downlaod source http://greatmaps.codeplex.com/SourceControl/list/changesets it's c# but it's exactly the same in vb.net/c++.net

Mar 30, 2011 at 11:04 AM

Von: radioman [email removed]
Gesendet: Dienstag, 29. März 2011 15:03
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

downlaod source http://greatmaps.codeplex.com/SourceControl/list/changesets it's c# but it's exactly the same in vb.net/c++.net

Mar 30, 2011 at 12:12 PM

rote?

Mar 30, 2011 at 12:37 PM

Route ??

Von: radioman [email removed]
Gesendet: Mittwoch, 30. März 2011 13:13
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

rote?

Mar 30, 2011 at 12:43 PM

check demos

Mar 30, 2011 at 1:07 PM

Thank you, i have the solution …. Dim route As MapRoute = GMaps.Instance.GetRouteBetweenPoints(start, ende, False, 17)

Von: radioman [email removed]
Gesendet: Mittwoch, 30. März 2011 13:44
An: sa-meier@gmx.de
Betreff: Re: Gmap Marker in VB.net [greatmaps:251490]

From: radioman

check demos