Draw a line between two waypoints in Map Streets

wolf

Member
Licensed User
Longtime User
hi,

I creat a array of waypoints and everything works correctly.
'Crée et initialize les marqueurs des waypoints
Dim Marker(nbMaxWP) As Marker
For i=0 To nbWP
Marker(i).Initialize("WP"&i, "WP"&i, pdv(i).lat, pdv(i).longi,Icon)
Next

' Initialize une liste des marqueurs
Dim Markers As List
Markers.Initialize
For i=0 To nbWP
Markers.Add(Marker(i))
Next

'Ajoute les marqueurs à l'overlay des marqueurs
MarkersOverlay1.Initialize(MapView1, "MarkersOverlay1")
MarkersOverlay1.AddMarkers(Markers)
'Ajoute l'overlay
MapView1.AddOverlay(MarkersOverlay1)

I wish to draw segments between two waypoints consecutifs .

But how can it be done ?

Thank you.

Best Regard

Wolf
 

wolf

Member
Licensed User
Longtime User
hi,

Thanks to all

Martin, I estimate largely and use your tutorials :sign0098:

But I badly expressed myself.

I desire to draw rectilinear lines between two consecutive waypoints to display the route. The meme thing that with Google Map in the attached file.

Best regards and good sunday

Wolf
 

Attachments

  • polygone.JPG
    polygone.JPG
    24.1 KB · Views: 485
Upvote 0

warwound

Expert
Licensed User
Longtime User
You can do that with the PathOverlay - you don't need to use it's AddGreatCircle method to create a polyline, just use one of it's AddPoint methods:

B4X:
Sub Process_Globals
   Dim MapCenter As GeoPoint
   Dim ZoomLevel As Int
   
   '   create a List to store the path points in Activity_Pause
   Dim PathPoints As List
End Sub

Sub Globals
   Dim MapView1 As MapView
   
   '   create the PathOverlay
   Dim PathOverlay1 As PathOverlay
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.AddMenuItem("Do something", "DoSomething")
   
   MapView1.Initialize("MapView1")
   Activity.AddView(MapView1, 0, 0, 100%x, 100%y)
   
   MapView1.SetMultiTouchEnabled(True)
   MapView1.SetZoomEnabled(True)
   
   '   initialize the PathOverlay and add it to the MapView, the path will be colored red
   PathOverlay1.Initialize(MapView1, Colors.Black)
   MapView1.AddOverlay(PathOverlay1)
   
   '   make the path 50% transparent (by default it is fully opaque)
   PathOverlay1.Alpha=128
   PathOverlay1.StrokeWidth=4
   
   If FirstTime Then
      PathPoints.Initialize
      
      PathOverlay1.AddPoint(52.7788, 0.4710)
      PathOverlay1.AddPoint(52.7543, 0.4482)
      PathOverlay1.AddPoint(52.7373, 0.4170)
      PathOverlay1.AddPoint(52.7599, 0.3970)
      PathOverlay1.AddPoint(52.7709, 0.4062)
      PathOverlay1.AddPoint(52.7788, 0.4710)
      
      PathPoints=PathOverlay1.GetAllPoints
      
      Log(PathPoints.Size) ' logs 6 points
      
      ' fit the map to the path
      MapView1.FitMapToBoundingBox(PathOverlay1.GetBoundingBox)
   Else
      '   restore map center and zoom level
      MapView1.Zoom=ZoomLevel
      MapView1.SetCenter3(MapCenter)
      
      '   restore the path points
      PathOverlay1.AddPoints(PathPoints)
   End If
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   MapCenter=MapView1.GetCenter
   ZoomLevel=MapView1.Zoom
End Sub

Sub DoSomething_Click
   '   set the map center and zoom level so that it contains the entire path
   MapView1.FitMapToBoundingBox(PathOverlay1.GetBoundingBox)
End Sub

I notice that on orientation change the last segment of the path is missing.
Maybe a bug in the PathOverlay it may be filtering out duplicate points..

I'll look at that later.

Martin.
 

Attachments

  • PathOverlay_wolf.zip
    6 KB · Views: 481
Upvote 0

wolf

Member
Licensed User
Longtime User
You gave me the information which missed me.

This post is closed for me

Thank you very much Martin.

Wolf
 
Upvote 0
Top