vb 2008 express, getting directions

May 29, 2009 at 12:45 PM
Edited May 29, 2009 at 1:02 PM

Hi, first of all congratulations for the great job.

I've managed to finally understand the way for getting the distance with your libraries. Now i want to get the directions like in the JavaScript api from google.

If you have any suggestions...

Best regards,

 Luís

Imports GMapNET

Public Class

 

 

 REM vars

 

Dim Gmap As New  GMap 

 

 Dim GmaprouteUse As GMapRoute

 

   Dim ResultadoPoints As List(Of  PointLatLng

 

 

 Dim pontos(1) As  PointLatLng

 

 

 

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Compute.Click

 

 

 

 REM geocoding

 

 

ResultadoPoints = GMaps.Instance.GetRouteBetweenPoints(pontos(0), pontos(1),False, 0) 

 

 REM insert start point, end point

coordorig.Text = pontos(0).ToString

coorddest.Text = pontos(1).ToString

 

 GmaprouteUse =New GMapRoute(pontos.ToList, "TEST")

 TextBox3.Text = ResultadoPoints.Count.ToString

 

  Dim cnt As Integer = ResultadoPoints.Count

 

  Dim distSeg As Double = 0

 

  Dim distTotal As Double = 0

 

 For ind As Integer = 0 To cnt - 2

 

 Dim pntsrota(ind) As PointLatLng

 

pntsrota(ind) = ResultadoPoints(ind)

distSeg = GMaps.Instance.GetDistance(ResultadoPoints(ind).Lat, _

                                                                               ResultadoPoints(ind).Lng, _

                                                                              ResultadoPoints(ind + 1).Lat, _

                                                                              ResultadoPoints(ind + 1).Lng)

distTotal += distSeg

'Debug.WriteLine(distSeg)

 

 Next

TextBox1.Text = distTotal.ToString

 

 ' Stop

 End Sub

 Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

 </font>

 

 Me.Close()

 

  

 End  Sub 

 

 

End Class

pontos(0) = GMaps.Instance.GetLatLngFromGeocoder(origem.Text)

pontos(1) = GMaps.Instance.GetLatLngFromGeocoder(destino.Text)

Coordinator
May 29, 2009 at 4:28 PM
Edited May 29, 2009 at 4:29 PM

in fact:

GMapRoute r = new GMapRoute(route, "test");
double roadLength = r.Distance;
p.s. about directions, i'll soon make the function to support that!

Jun 2, 2009 at 7:56 AM

Thanks,

 

I’m going to try some ideas,

Keep the good work

 

 

Luís