Hello, is it possible to have text/labels on a polygon and circles in Google Map on Android?
Something like this, more centered in the middle.
Thank you.
My "solution" to this only works for Circles. For circle, you need to find the center of the circle and then create a marker using (gmap.AddMarker3) to add in a bitmap marker that is just the text.
I'm not sure how to apply this "solution" to a polygon since polygons can have a weird shape.
Example for circle: Using TextToBitmap function by Erel here
You would get something like this:
I don't know how to perfectly center the text, or how to auto calculate how big the text needs to be, but it works.
Anyways, I guess to clarify what my questions are:
1. Is there a built-in method of adding text/labels to Circles/Polygon?
2. If there isn't, if I use my solution, how can I calculate the center of a polygon?
3. Is there a way to calculate so that the text is in the center of the circle and the font size is automatic?
thank you !
Something like this, more centered in the middle.
Thank you.
My "solution" to this only works for Circles. For circle, you need to find the center of the circle and then create a marker using (gmap.AddMarker3) to add in a bitmap marker that is just the text.
I'm not sure how to apply this "solution" to a polygon since polygons can have a weird shape.
Example for circle: Using TextToBitmap function by Erel here
B4X:
Dim co As CircleOptions
co.Initialize
co.Center2(40, 40).Radius(1609).FillColor(Colors.ARGB(150, 255, 229, 179)).StrokeColor(Colors.ARGB(150, 240, 58, 23)).StrokeWidth(2.0)
gmapExtra.AddCircle(gmap, co)
'Here we will add the text for the circle, using the center's LatLng
Dim bmp As Bitmap = TextToBitmap(100dip, xui.CreateDefaultBoldFont(10), xui.Color_Black, "Text for Circle")
Dim m As Marker = gmap.AddMarker3(RadaiiSection.Get("Lat"), RadaiiSection.Get("Lng"),"", bmp)
You would get something like this:
I don't know how to perfectly center the text, or how to auto calculate how big the text needs to be, but it works.
Anyways, I guess to clarify what my questions are:
1. Is there a built-in method of adding text/labels to Circles/Polygon?
2. If there isn't, if I use my solution, how can I calculate the center of a polygon?
3. Is there a way to calculate so that the text is in the center of the circle and the font size is automatic?
thank you !
Last edited: