Android Question Google Map Rotate Marker

iCAB

Well-Known Member
Licensed User
Hi All

I am unable to rotate a marker after it has been added

Here is the code I am using
B4X:
MarkerOptions1.Initialize
    MarkerOptions1.Flat(True)
    MarkerOptions1.Position2(dbLat, dbLng).Snippet(Snippet).Title(Title).Visible(blnVisible)
   
    Dim BitmapDescriptor1 As BitmapDescriptor
    Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory
    BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset(IconFile)
    MarkerOptions1.Icon(BitmapDescriptor1)
   
    Marker1 = GoogleMapsExtras1.AddMarker(gmap, MarkerOptions1)
   
'This line doesn't work. 
    MarkerOptions1.Rotate(90)
if I move .Rotate above AddMarker the marker rotates properly, however my goal is to rotate markers after they have been added

Can you please let me know what is wrong with the above code

Thanks in advance
 

iCAB

Well-Known Member
Licensed User
Thanks eurojam, works perfect.
Is there a similar thing that allows updating the icon dynamically.
 
Last edited:

eurojam

Well-Known Member
Licensed User
Is there a similar thing that allows updating the icon dynamically.
If you want to change the Markericon, I would suggest to use two markers at the same point with the different icons and switch the visiblity, so you will have the effect of changing the icon dynamically.

the 2 attached screenshots shows this as an example. There are treasureboxes and when the user clicks the icon it will be an opened treasure box...I think that is what you mean?

Screenshot_20160223-101344.png
Screenshot_20160223-101403.png
 
Last edited:

eurojam

Well-Known Member
Licensed User
Cool your app!
Thanks, for that. The code was developed for a customer, I am sorry, but I can not post the whole project. But if you have questions concerning anything, I will try to answer it, if possible.

best regards
stefan
 

warwound

Expert
Licensed User
Look at this Stackoveflow page:
http://stackoverflow.com/questions/14449870/change-marker-icon-during-runtime

Looks like at some point the GoogleMap API was updated and now allows both Marker Rotation and Icon to be set/changed after the Marker has been added to the map.

Another page worth a look:
https://developers.google.com/maps/documentation/android-api/releases

That's the GoogleMap API changelog and you can see there's been a few API updates made since i last updated GoogleMapsExtras.
So when i have time i'll update GoogleMapsExtras to add the newer features.

In the meantime i'm sure you can still test and see if it's possible to change a Marker Icon after the Marker has been added to the map?
 
Top