Drawing on a map

Post your Gambas programming questions here.
Post Reply
seany
Posts: 32
Joined: Friday 6th December 2019 3:09pm

Drawing on a map

Post by seany »

Hello

I want to dynamically add points on a gb.map

I have :
Public Sub _New()

MapView1.Map.AddTile("OpenStreet", "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
 MapView1.Map.AddShape("P")

End
then, this function is called periodically :
Public Sub drawPoint()
  Dim c As String 
  c = Str(Rand(65, 90))
  Print "drawing " & pointLat & " " & pointLon & " " & timeStamp
 
  MapView1.Map["P"].AddPoint("c", MapPoint(pointLat, pointLon))
  MapView1.Map.Center(pointLat, pointLon)
  
End
I get the error : this key already exists in Fmain:20

How to solve this? Thank you
seany
Posts: 32
Joined: Friday 6th December 2019 3:09pm

Re: Drawing on a map

Post by seany »

Okey, I solved it by randomizing the key

Code: Select all

"c"
.

Having initiated the the key at the drawPoint function - given we are working with a pseudorandom - generate the same key every time.

Having generated the key at the loop where the drawPoint function is being called solves the issue.
Post Reply