Android Question Draw on gmap snippet

Blueforcer

Well-Known Member
Licensed User
Longtime User
Hello!

Is it possible to draw on a googleMaps snippet?
I need to draw a heathbar over a gmap marker.
I 've tried to draw in the markers Icon. But that goes totally wrong:(
 

eurojam

Well-Known Member
Licensed User
Longtime User
I would work with an InfoWindowAdapter where you can add different views like imageview to the infowindow of a marker.
in the map_ready event you define:
B4X:
  Dim InfoWindowAdapter1 As InfoWindowAdapter
    InfoWindowAdapter1.Initialize("InfoWindowAdapter1")
  GoogleMapsExtras1.SetInfoWindowAdapter(gmap, InfoWindowAdapter1)
  
  InfoWindowPanel.Initialize("")
  InfoWindowPanel.LoadLayout("MapInfoWindow") 'Load your layout with whatever
  '  a hack(ish) way to set InfoWindowPanel width and height!
  MapPanel.AddView(InfoWindowPanel, 0, 0, 270dip, 200dip) 
  InfoWindowPanel.RemoveView
later in the Sub InfoWindowAdapter1_GetInfoContents(Marker1 As Marker) you can set the views to content depending on the marker.
see this thread for more information: https://www.b4x.com/android/forum/threads/googlemapsextras.26277/ or search for InfoWindowAdapter
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
I managed it yet to draw in the icon, so i can use the InfoWindowAdapter and for other Information. But thanks for the tip!

here is my code:

B4X:
Sub drawHealth (Health As Int)  As Bitmap

    Dim b As Bitmap
    Dim newBMP As Bitmap
    Dim brect As Rect
    Dim barRect As Rect
    Dim healthRect As Rect
    Dim orgHealth As Int
   
    b = LoadBitmap(File.DirAssets, "chest.png")
    newBMP.InitializeMutable(b.Width,b.Width)
    brect.Initialize(0,0,b.Width, b.Height)
  
      barRect.Initialize(0,0,b.Width-1,4.5dip)
     
    c.Initialize2(newBMP)
    c.DrawBitmap(b,Null,brect)
    c.DrawRect(barRect,Colors.Black,False,1)
    Health = (Health/100)*(b.Width-2)
   
    healthRect.Initialize(2,2,Health,4.5dip -1)
   
    c.DrawRect(healthRect,Colors.RGB(2.55 * (1 - orgHealth),2.55 * orgHealth, 0),True,1)
   
   

   
 
'c.DrawBitmap(newBMP, Null, brect)
  
    Return c.Bitmap
   
End Sub
 
Upvote 0

gudino jose luis

Active Member
Licensed User
Longtime User
Hello
I can possible to include individual attributes to google Maps snippet
ie highlighted letters, line feed, or other.
Thank
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
yes you can do this using InfoWindowAdapter. See my post above with the link

Screenshot_20160614-080652.jpg
 
Upvote 0
Top