Android Question Google Maps Marker radius bounds

prajinpraveen

Active Member
Licensed User
Longtime User
thanks Erel, there are more than 500 custom points on the map. i would like to show only markers that are in 10km vicinity of the current location.
i was thinking if i could get the northeast and southwest (bounds) from the current location, i could run a query to find out the markers within the boundary.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Start simple. It takes 5 milliseconds to calculate the distance between a point and a list of 1000 points.
B4X:
Sub Process_Globals
   Private allpoints As List
End Sub

Sub Service_Create
   allpoints.Initialize
   For i = 1 To 1000
     Dim loc As Location
     loc.Initialize
     loc.Latitude = Rnd(-90, 90)
     loc.Longitude = Rnd(-180, 180)
     allpoints.Add(loc)
   Next
   Dim n As Long = DateTime.Now
   Dim res As List
   res.Initialize
   Dim loc As Location
   loc.Initialize
   loc.Latitude = 30
   loc.Longitude = 30
   For Each p As Location In allpoints
     Dim dist As Double = p.DistanceTo(loc)
     If dist < 10000 Then res.Add(p)
   Next
   Log(DateTime.Now - n)
   Log(res)
End Sub
 
Upvote 0
Top