GoogleMapsExtras RemoveCircle?

me68

Member
Licensed User
Longtime User
Hello!

I'm using GoogleMaps & GoogleMapsExtras libraries as part of an app for an electric vehicle. Therefore i draw a light green circle around the current position with radius=remaining range/autonomie of the car, a second darker circle with radius=half autonomie and a red dot for the car itself.

GPS lat & GPS lon is used via a timer with 1000msec to update the map.

Since i know no sub similiar RemoveCircle i have to build the map from stratch every second. So it's blinking on drawing the green circles. That's not so nice viewing.

The other problem is if i have a lot of POIs the device can't follow with the updates in 1000msec, because the POIs are also generated in this update-sub.

Is there a RemoveCircle available or another solution dealing with this?


...
gmap.Clear
Try
cur = SQL1.ExecQuery("SELECT * FROM POIS;")
If cur.RowCount > 0 Then
For i = 0 To cur.RowCount - 1
cur.Position = i
sGPS_Lat = cur.GetString2(0)
sGPS_Lon = cur.GetString2(1)
sName = cur.GetString2(2)
sDesc = cur.GetString2(3)

gmap.AddMarker(sGPS_Lat, sGPS_Lon, sName)
Next
End If
cur.Close
Catch
End Try

coRemainingRange.Initialize
coRemainingRange.Center2(scanner.Gps_Lat, scanner.Gps_Lon).FillColor(Colors.ARGB(50,0,255,51)).Radius(scanner.autonomie * 1000).StrokeColor(Colors.Black).StrokeWidth(0)
cRemainingRange = gmape.AddCircle(gmap, coRemainingRange)
coRemainingRange.Center2(scanner.Gps_Lat, scanner.Gps_Lon).FillColor(Colors.ARGB(60,0,255,51)).Radius(scanner.autonomie * 1000 / 2).StrokeColor(Colors.Black).StrokeWidth(0)
cRemainingRange = gmape.AddCircle(gmap, coRemainingRange)
coRemainingRange.Center2(scanner.Gps_Lat, scanner.Gps_Lon).FillColor(Colors.Red).Radius(dRadius).StrokeColor(Colors.Black).StrokeWidth(0)
cRemainingRange = gmape.AddCircle(gmap, coRemainingRange)

cpRemainingRange.Initialize(scanner.Gps_Lat, scanner.Gps_Lon, iZoomLevel)
gmap.AnimateCamera(cpRemainingRange)
...



Martin
 

me68

Member
Licensed User
Longtime User
It looks like following:

file.php


Martin
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Look at the available methods and properties:

  • Circle
    Methods:
    • IsInitialized As Boolean
    • Remove
      Remove the Circle from the map.
    Properties:
    • Center As LatLngWrapper
      Get or Set the Circle center.
    • FillColor As Int
      Get or Set the Circle fill color.
    • Id As String [read only]
      Get the Circle Id.
    • Radius As Double
      Get or Set the Circle radius in meters.
    • StrokeColor As Int
      Get or Set the Circle stroke color.
    • StrokeWidth As Float
      Get or Set the Circle stroke width.
    • Visible As Boolean
    • ZIndex As Float
      Get or Set the Circle ZIndex.

Circle has a Remove method.
It also has a Center property.

I'd expect you could simply change the Center and then, as you're not redrawing the entire map on each update, your problem with the POIs should hopefully be fixed too.
Circle has other properties that can be set too so there is really nor reason to even think about removing, re-creating and re-adding a Circle to the map.

(another) Martin.
 
Upvote 0

me68

Member
Licensed User
Longtime User
Hello Martin!

Thanks to put me in the right direction.

I use now

Dim cAutonomie1 As Circle
Dim llCurrentPos As LatLng
llCurrentPos.Initialize(scanner.Gps_Lat, scanner.Gps_Lon)
cAutonomie1.Center(llCurrentPos)


But on compiling a get an error. Why is an array expected?

Parsing code. 0.20
Compiling code. Error
Error compiling program.
Error description: Array expected.
Occurred on line: 1124
cAutonomie1.Center(llCurrentPos)
Word: (


Martin
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Dim llCurrentPos As LatLng
llCurrentPos.Initialize(scanner.Gps_Lat, scanner.Gps_Lon)
cAutonomie1.Center(llCurrentPos)

Center is a property not a method.
Try:

B4X:
Dim llCurrentPos As LatLng
llCurrentPos.Initialize(scanner.Gps_Lat, scanner.Gps_Lon)
cAutonomie1.Center=llCurrentPos

mARTIN.
 
Upvote 0

me68

Member
Licensed User
Longtime User
Hello Martin!

One more question: I want to add the select satellite/card control, but i do not find the right method/property. Is this also available in b4a?

Martin
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
The b4a GoogleMap object has a MapType property you use to set the map type - road map, satellite etc:

    • GoogleMap
      Fields:
      • MAP_TYPE_HYBRID As Int
      • MAP_TYPE_NONE As Int
      • MAP_TYPE_NORMAL As Int
      • MAP_TYPE_SATELLITE As Int
      • MAP_TYPE_TERRAIN As Int
      Properties:
    • MapType As Int
      Gets or sets the map type. The value should be one of the MAP_TYPE constants.

So you'd set satellite map type with code such as:

B4X:
MyGoogleMap.MapType=MyGoogleMap.MAP_TYPE_SATELLITE

There's no built in map type control (that i know of) that can be enabled, you'll have to create your own such control to allow the user to select the map type.

mARTIN.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Is it possible with GoogleMapsExtras to restrict min and max zoom level on a map?

No, the built in map types (road map, satellite, hybrid etc) all have min and max zoom levels that cannot be modified.

You could instead listen for the MapFragment CameraChange event.
If the new CameraPosition displays the map at a zoom level you don't want to be displayed then adjust the zoom level in the event handler.
Not sure how well this would work but i think it's your only option.

Martin.
 
Upvote 0
Top