Look at the GoogleMapsExtras InfowindowAdapter to customize the infowindow.
Martin.
Sent from my GT-I9300 using Tapatalk 2
Sub InfoWindowAdapter1_GetInfoWindow(Marker1 As Marker) As View
' the default InfoWindow will be used if this event Sub is not defined or if it returns Null
Log("InfoWindowAdapter1_GetInfoWindow")
'Dim InfoWindowLabel As Label
'InfoWindowLabel.Initialize("")
'InfoWindowLabel.Color=Colors.Red
'InfoWindowLabel.TextColor=Colors.White
'InfoWindowLabel.Initialize("")
Dim InfoWindowPanel As Panel
InfoWindowPanel.Initialize("")
InfoWindowPanel.Color = Colors.Gray
Dim PicLocal As ImageView
PicLocal.Initialize("")
PicLocal.Bitmap = LoadBitmap(File.DirAssets,"map_marker_32.png")
PicLocal.BringToFront
MapPanel.AddView(InfoWindowPanel, 0,0,150dip,80dip)
InfoWindowPanel.AddView(PicLocal,10,10,40,40)
'InfoWindowLabel.Text=Marker1.Title&CRLF&Marker1.Snippet
Return InfoWindowPanel
End Sub
Sub Process_Globals
End Sub
Sub Globals
Dim ContainerPanel As Panel
Dim GoogleMap1 As GoogleMap
Dim InfoWindowPanel As Panel
Dim MapFragment1 As MapFragment
Dim MapPanel As Panel
Dim Markers As Map
Dim SnippetLabel As Label
Dim ThumbImage As ImageView
Dim TitleLabel As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
If MapFragment1.IsGooglePlayServicesAvailable = False Then
ToastMessageShow("Google Play services not available.", True)
Else
MapFragment1.Initialize("MapFragment1", MapPanel)
End If
End Sub
Sub MapFragment1_Ready
Log("MapFragment1_Ready")
GoogleMap1 = MapFragment1.GetMap
If GoogleMap1.IsInitialized = False Then
ToastMessageShow("Error initializing map.", True)
Else
Dim GoogleMapsExtras1 As GoogleMapsExtras
Dim InfoWindowAdapter1 As InfoWindowAdapter
InfoWindowAdapter1.Initialize("InfoWindowAdapter1")
GoogleMapsExtras1.SetInfoWindowAdapter(GoogleMap1, InfoWindowAdapter1)
InfoWindowPanel.Initialize("")
InfoWindowPanel.LoadLayout("InfoWindow")
' a hack(ish) way to set InfoWindowPanel width and height!
MapPanel.AddView(InfoWindowPanel, 0, 0, 280dip, 120dip)
InfoWindowPanel.RemoveView
Markers.Initialize
Dim Marker1 As Marker
Marker1=GoogleMap1.AddMarker(52.75619, 0.3980, "Home Sweet Home")
Marker1.Snippet="Home is where the heart is!"
Markers.Put(Marker1, Marker1)
Dim Marker1 As Marker
Marker1=GoogleMap1.AddMarker(52.93514, 0.4829, "Hunstanton")
Marker1.Snippet="A charming seaside town. Popular with the tourists."
Markers.Put(Marker1, Marker1)
Dim CameraPosition1 As CameraPosition
CameraPosition1.Initialize(52.75619, 0.3980, 8)
GoogleMap1.AnimateCamera(CameraPosition1)
End If
End Sub
Sub InfoWindowAdapter1_GetInfoContents(Marker1 As Marker) As View
' Return Null
' the default InfoContent will be used if this event Sub is not defined or if it returns Null
Log("InfoWindowAdapter1_GetInfoContents")
TitleLabel.Text=Marker1.Title
SnippetLabel.Text=Marker1.Snippet
' ThumbImage.Bitmap=? how will you store the file path/file name of the image to display?
' it's a shame that the Marker object has no Tag property which could be used to store such info
Return InfoWindowPanel
End Sub
Sub MapFragment1_MarkerClick (SelectedMarker As Marker) As Boolean
Log(SelectedMarker.Position.Latitude)
Return True
End Sub
Note: The info window that is drawn is not a live view. The view is rendered as an image (using View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (for example, after an image has loaded), call showInfoWindow(). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.
Error occurred on line: 359 (main)
java.lang.RuntimeException: Object should first be initialized (OnInfoWindowClickListener).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:46)
at com.trix.main._map_ready(main.java:1989)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:305)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:162)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:158)
at anywheresoftware.b4a.objects.MapFragmentWrapper$MyMapFragment.onViewCreated(MapFragmentWrapper.java:191)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:899)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
at android.app.BackStackRecord.run(BackStackRecord.java:682)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5095)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
Sub Map_Ready
gMap = mFragment.GetMap
If gMap.IsInitialized = False Then
ToastMessageShow("Error initializing map", True)
Else
gMap.MyLocationEnabled=True
gMap.GetUiSettings.ZoomControlsEnabled=False
gMap.GetUiSettings.MyLocationButtonEnabled=False
'INFO WINDOW ADAPTER
Dim InfoWindowAdapter1 As InfoWindowAdapter
InfoWindowAdapter1.Initialize("InfoWindowAdapter1")
gXtra.SetInfoWindowAdapter(gMap, InfoWindowAdapter1)
InfoWindowPanel.Initialize("")
InfoWindowPanel.LoadLayout("Layout_InfoWindowPanel")
pnlMap.AddView(InfoWindowPanel, 0, 0, 170dip, 65dip)
InfoWindowPanel.RemoveView
'MAP PADDING
' gXtra.SetPadding(gMap, 0, 80, 0, 0)
Dim icl As OnInfoWindowClickListener
icl.Initialize("InfoWindowClick")
gXtra.SetOnInfoWindowClickListener(gMap, icl) ' == THIS LINE GENERATES ERROR ABOVE
End If
End Sub
Sub InfoWindowClick(Marker As Marker)
Log("InfoWindowClick")
End Sub
'MAP PADDING
gXtra.SetPadding(gMap, 0, 80, 0, 0)
Cannot get methods of class: uk.co.martinpearman.b4a.googlemapsextras.GoogleMapsExtras, disabling cache.
Sub InfoWindowClick_Click(Marker As Marker)
Log("InfoWindowClick_Click")
End Sub
Can you upload a sample project with custom annotations.
the link of your example is not found. (http://android.martinpearman.co.uk/b4a/temp/CustomInfoWindow.zip.)