Android Question GoogleMap marker icon is clipped

MikeH

Well-Known Member
Licensed User
Does anyone know why:

B4X:
Mrk = Gmap.AddMarker3(x, y, Name, LoadBitmap(Dir, "icon.png"))
Shows all of the marker icons like this: (Android)



They should look like this: (iOS)



These are the same two marker icons (one says OR, other says CR), above is Android, below is iOS.

Thanks for your help :)
 

MikeH

Well-Known Member
Licensed User
They are downloaded as 20 x 20. It seems Google only allow use of 16 x 16.

Edit: I tried 32 x 32 and that works perfectly. Maybe only multiples of 16 works?
 
Last edited:

eurojam

Well-Known Member
Licensed User
Mike,
I think it is not a problem of the resolution. It seems more that the googlemaps api will not work with bitmaps properly. I have similar problems with an overlay. you can try to load them as a bitmap drawable. Put them into the res/drawable or drawable-hdpi folder as read only and then use some code like this one:
B4X:
...
       Dim AndroidResources1 As AndroidResources
       Dim Icon1 As Bitmap
       Dim MyDrawable1 As BitmapDrawable
       MyDrawable1=AndroidResources1.GetApplicationDrawable("myicon")
       Icon1=MyDrawable1.Bitmap
       Dim BitmapDescriptor1 As BitmapDescriptor
       Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory
       BitmapDescriptor1=BitmapDescriptorFactory1.FromBitmap(Icon1)         
       Dim MarkerOptions1 As MarkerOptions
       MarkerOptions1.Initialize
        MarkerOptions1.Position2(lat,lon).Snippet("").Title("will see if it works...").Visible(True)
       MarkerOptions1.Icon(BitmapDescriptor1)
       MarkerOptions1.Anchor(0.5,0.5)
       Dim Marker1 As Marker=GoogleMapsExtras1.AddMarker(GoogleMap1, MarkerOptions1)
...
Best regards
stefan
 

MikeH

Well-Known Member
Licensed User
Thanks Stefan, I did find that solution in another thread but these icons are downloaded and change from time to time so I can`t include them in the code.
 

eurojam

Well-Known Member
Licensed User
you can also try to make the bitmapdescriptor like this:
B4X:
BitmapDescriptor1=BitmapDescriptorFactory1.FromPath(aDir & "/icon.png")
 

MikeH

Well-Known Member
Licensed User
Thanks EJ, I tried that too, didnt work.

I spoke to the place that provides the icons and asked them to change to 32 x 32 :)
 
Top