Android Question GoogleMap marker icon is clipped

Discussion in 'Android Questions' started by MikeH, Jun 1, 2015.

  1. MikeH

    MikeH Well-Known Member Licensed User

    Does anyone know why:

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

    [​IMG]

    They should look like this: (iOS)

    [​IMG]

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

    Thanks for your help :)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    What are the images sizes?
     
  3. MikeH

    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: Jun 1, 2015
  4. eurojam

    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:
    Code:
    ...
           
    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
     
  5. MikeH

    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.
     
  6. eurojam

    eurojam Well-Known Member Licensed User

    you can also try to make the bitmapdescriptor like this:
    Code:
    BitmapDescriptor1=BitmapDescriptorFactory1.FromPath(aDir & "/icon.png")
     
  7. MikeH

    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 :)
     
  8. juventino883

    juventino883 Member Licensed User

    I have the same problem I scale the icon to 48x48 and the marker icon is clipped :s
     
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