Display marker label at all times on Google Maps. Is multiline possible?

adrianstanescu85

Active Member
Licensed User
Longtime User
Hello

I have an app that integrates Google maps (successfully) and I added a few markers (5 at most). They display just fine, each one is also given a label since they're added by "AddMarker2", but what I'd really need is that specific label to be shown (visible) at all times.

I get each of them visible by clicking on the marker bubble with the tablet stylus (I use a Samsung Note 10.1 N8000), but I'd need to see all those labels without clicking anything, how can this be done?

Also, is it possible that instead of showing just "MS64SMU" for a label I'd be able to show a 'multi-line' label that has "MS64SMU" on a first row and "TIM" on a second row, for the same label?

Thank you!
 

systems1

Member
Licensed User
Longtime User
I used <br> but it is not working see my code
B4X:
MarkerOptions1.Position2(36.051458, -95.971462).Snippet("This is a line break</br>My new line is here").Title("Test info window").Visible(True)
 
Upvote 0

systems1

Member
Licensed User
Longtime User
Hello,

Thanks for your replay, I tried with this but I did't see any change. I attached a screenshot please see it.

Please help me.
 

Attachments

  • 2013-08-26_17-53-33.png
    2013-08-26_17-53-33.png
    337.6 KB · Views: 4,442
Upvote 0

warwound

Expert
Licensed User
Longtime User
Look at LabelExtras library and it's HTML object.
It might br able to render basic html tags in infowindows.

martim.
 
Upvote 0

systems1

Member
Licensed User
Longtime User
I tried with the html object but it is not breaking the line.
This is my code
B4X:
Dim Html1 As Html
Dim htmlstr As String

htmlstr = Html1.FromHtml("<div>This is a line break <BR />My new line is here</div>")
MarkerOptions1.Position2(36.051458, -95.971462).Snippet(htmlstr).Title("Test info window").Visible(True)
 
Upvote 0

dibesw

Active Member
Licensed User
Longtime User
HI,
I tried but I could not find;
is it possible display title of a marker when I push a button? (like this)

map3.jpg


THANKS!
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
The Marker object has a property named InfoWindowShown.
As long as you have a reference to your Marker then in your button click sub you can do:

B4X:
MyMarker.InfoWindowShown=True

Martin.
 
Upvote 0

dibesw

Active Member
Licensed User
Longtime User
Thanks worwound,
but I have e.g. 10 marker displayed.
How I can display title of one of this?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Ideally you want to create an Array of Markers when your create each individual Marker, now as you have a reference to each Marker you can set it's InfoWindowShown property.

Alternatively create a List containing Marker objects, or even a Map where the Map values are Marker objects.

If you're still stuck can you post some code or even a project that shows how you're creating your Marker objects - i'll se how it can be updated to also create an Array, List or Map.

Martin.
 
Upvote 0

dibesw

Active Member
Licensed User
Longtime User
This is my code:

B4X:
Sub Map_Ready
  Dim LatLngBoundsBuilder1 As LatLngBoundsBuilder
  LatLngBoundsBuilder1.Initialize
  gmap = mFragment.GetMap
  If gmap.IsInitialized = False Then
      ToastMessageShow("Error initializing map.", True)
  Else
      Dim i As Int
      For i = 0 To listaweb.Size - 1
        Dim Marker1 As Marker
        'Dim MarkerE As MarkerExtras
        'Dim MarkerO As MarkerOptions
        Dim P As Ptype
        P = listaweb.Get(i)
        Marker1=gmap.AddMarker3(P.latit, P.longi, P.nome, ico)
        LatLngBoundsBuilder1.Include(Marker1.Position)
        Marker1.Draggable=True
      Next
      Dim cp As CameraPosition
      cp.Initialize(Main.LatGPS, Main.LonGPS, 15)
      gmap.MoveCamera(cp)
  End If
  Dim MarkerBounds As LatLngBounds=LatLngBoundsBuilder1.Build
  gmapEX.AnimateToBounds2(gmap, MarkerBounds, 70%x-1dip, 90%y, 128)
End Sub

I show more marker from listaweb.
These markers not have text title.
Then I would like to show text title only that one of this, but don't know how I can selection this marker.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Look at this:

B4X:
Sub Globals
	' create a new Map object (a Map not a GoogleMap!)
	Dim Markers As Map
End Sub

Sub Map_Ready
  Dim LatLngBoundsBuilder1 As LatLngBoundsBuilder
  LatLngBoundsBuilder1.Initialize
  gmap = mFragment.GetMap
  If gmap.IsInitialized = False Then
      ToastMessageShow("Error initializing map.", True)
  Else
		Markers.Initialize
		Dim i As Int
		For i = 0 To listaweb.Size - 1
			Dim Marker1 As Marker
			'Dim MarkerE As MarkerExtras
			'Dim MarkerO As MarkerOptions
			Dim P As Ptype
			P = listaweb.Get(i)
			Marker1=gmap.AddMarker3(P.latit, P.longi, P.nome, ico)
			LatLngBoundsBuilder1.Include(Marker1.Position)
			Marker1.Draggable=True
			Markers.Put("marker_"&i, Marker1)
		Next
		Dim cp As CameraPosition
		cp.Initialize(Main.LatGPS, Main.LonGPS, 15)
		gmap.MoveCamera(cp)
  End If
  Dim MarkerBounds As LatLngBounds=LatLngBoundsBuilder1.Build
  gmapEX.AnimateToBounds2(gmap, MarkerBounds, 70%x-1dip, 90%y, 128)
End Sub

Sub MyButton_Click
	Dim MarkerId As String="marker_0"
	Dim Marker1 As Marker=Markers.Get(MarkerId)
	Marker1.InfoWindowShown=True
End Sub

I've created a Global Map object named Markers, the Map keys are Strings such as 'marker_0', 'marker_1' and the values are Marker objects.

MyButton_Click gets a reference to a Marker 'marker_0' and open the infowindow on it.

So you need a plan - how to give your Marker objects meaningful names that you can later use to get a reference to them.

Martin.
 
Upvote 0
Top