Android Question Google Map Rotate Marker

Discussion in 'Android Questions' started by iCAB, Feb 20, 2016.

  1. iCAB

    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
    Code:
    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
     
  2. eurojam

    eurojam Well-Known Member Licensed User

    did you try
    Code:
    Dim  mx As MarkerExtras
    mx.SetRotation(Marker1,
    45)
     
  3. iCAB

    iCAB Well-Known Member Licensed User

    Thanks eurojam, works perfect.
    Is there a similar thing that allows updating the icon dynamically.
     
    Last edited: Feb 20, 2016
  4. eurojam

    eurojam Well-Known Member Licensed User

    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: Feb 23, 2016
    inakigarm, lemonisdead and DonManfred like this.
  5. Alisson

    Alisson Active Member Licensed User

    Share the app with users?
    Cool your app!
     
  6. eurojam

    eurojam Well-Known Member Licensed User

    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
     
  7. iCAB

    iCAB Well-Known Member Licensed User

    Thanks eurojam.
    By the way... looks really nice
     
  8. warwound

    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?
     
    eurojam likes this.
  9. Alisson

    Alisson Active Member Licensed User

    Thanks eurojam and warwound! :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice