Drawing on a map

Post

Posted
Rating:
#1 (In Topic #346)
Regular
seany is in the usergroup ‘Regular’
Hello

I want to dynamically add points on a gb.map

I have :

Code (gambas)

  1. Public Sub _New()
  2.  
  3. MapView1.Map.AddTile("OpenStreet", "http://\{s}.tile.openstreetmap.org/\{z}/\{x}/\{y}.png")
  4.  MapView1.Map.AddShape("P")
  5.  
  6.  

then, this function is called periodically :

Code (gambas)

  1. Public Sub drawPoint()
  2.   Dim c As String
  3.   c = Str(Rand(65, 90))
  4.   Print "drawing " & pointLat & " " & pointLon & " " & timeStamp
  5.  
  6.   MapView1.Map["P"].AddPoint("c", MapPoint(pointLat, pointLon))
  7.   MapView1.Map.Center(pointLat, pointLon)
  8.  
  9.  
I get the error : this key already exists in Fmain:20

How to solve this? Thank you
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
seany is in the usergroup ‘Regular’
Okey, I solved it by randomizing the key

Code

"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.
Online now: No Back to the top
1 guest and 0 members have just viewed this.