B4J Question Google Map rotate event?

javiers

Active Member
Licensed User
Longtime User
Hello, I would like that when rotating the map the marker icon (in this case the red arrow) could also change, adapting to the rotation.
Is this possible?
Thanks in advance.

(Google translator)

Imagen sin título2.jpg
 

javiers

Active Member
Licensed User
Longtime User
Upvote 0

javiers

Active Member
Licensed User
Longtime User
I have included the GoogleMapsExtras library and put the following code, following the example https://www.b4x.com/android/forum/threads/old-google-maps-android-v2-tutorial.24415/post-152012

B4J:
Sub RemoveButton_Click
    GroundOverlay1.Remove
End Sub

Sub VisibilityButton_Click
    Dim GroundOverlayOptions1 As GroundOverlayOptions
    Dim LatLngBounds1 As LatLngBounds
    Dim SouthWest, NorthEast As LatLng
        
    SouthWest.Initialize(40.712216,-74.22655)
    NorthEast.Initialize(40.773941,-74.12544)
    LatLngBounds1.Initialize(SouthWest, NorthEast)
    Dim GoogleMapsExtras1 As GoogleMapsExtras
    GroundOverlayOptions1.Initialize
    GroundOverlayOptions1.Image(xui.LoadBitmap(File.DirAssets, "newark_nj_1922.jpg")).PositionFromBounds(LatLngBounds1).SetTransparency(0.2)

    GroundOverlay1=GoogleMapsExtras1.AddGroundOverlay(GMap, GroundOverlayOptions1)
        
    Dim CameraPosition1 As CameraPosition
    CameraPosition1.Initialize(40.7395, -74.175, 12)
    GMap.MoveCamera(CameraPosition1)
'    GroundOverlay1.Visible=Not(GroundOverlay1.IsVisible)
End Sub


When compiling I get the following error

B4J Versión: 9.80
Parseando código. (0.24s)
Java Versión: 19
Building folders structure. (0.12s)
Compilando código. (0.62s)
Compilado códigos de diseños. (0.03s)
Organizando librerías. (0.00s)
Compilando el código Java generado. Error
B4J line: 6109
LatLngBounds1.Initialize(SouthWest, NorthEast)
src\jsouto\ics\sitac\main.java:14084: error: package com.google.android.gms.maps.model does not exist
_latlngbounds1.Initialize((com.google.android.gms.maps.model.LatLng)(_southwest.getObject()),(com.google.android.gms.maps.model.LatLng)(_northeast.getObject()));
^
1 error
only showing the first 1 errors, of 6 total; use -Xmaxerrs if you would like to see more
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
My mistake. Didn't notice that it is a B4J question.

You can draw an arrow as a polyline:
B4X:
Dim points As List
points.Initialize
Dim RawPoints As String = "34.8598741°E 31.9144749°N, 34.8631059°E 31.9165439°N, 34.8628081°E 31.9149610°N, 34.8631059°E 31.9165439°N, 34.8604497°E 31.9166584°N"
For Each rp As String In Regex.Split(",\s*", RawPoints)
    points.Add(GisPointToLatLng(rp))
Next
gmap.AddPolyline(points, 5, fx.Colors.Red)
Dim cp As CameraPosition
Dim p As LatLng = GisPointToLatLng("34.8598741°E 31.9144749°N")
cp.Initialize(p.Latitude, p.Longitude, 15)
gmap.MoveCamera(cp)

Private Sub GisPointToLatLng (s As String) As LatLng
    Dim m As Matcher = Regex.Matcher("(\d+\.\d+)[^\d]+(\d+\.\d+)", s)
    m.Find
    Dim ll As LatLng
    ll.Initialize(m.Group(2), m.Group(1))
    Return ll
End Sub

How did you add the rotation button? I wasn't able to rotate the map.
 
Upvote 0

javiers

Active Member
Licensed User
Longtime User
Thanks for your answer.

The rotation button appears directly in certain areas by "itself".

1701067329327.png


It would be easier for me to be able to capture the map rotation event in order to change the image associated with the marker.
 
Upvote 0
Top