mobile-sdk
mobile-sdk copied to clipboard
Is it possible to force Text objects to have a maximum width?
Hi,
I'm trying to add some points along with their text over the map using the following code:
private fun addRoutes(routesVectorDataSource: LocalVectorDataSource) {
val vectorElementVector = VectorElementVector()
routes.forEach { route ->
val originLatitude = route.origin_latitude
val originLongitude = route.origin_longitude
val pointPos = baseProjection.fromLatLong(originLatitude, originLongitude)
val point = Point(pointPos, getRoutePointStyle())
vectorElementVector.add(point)
val markerText = Text(pointPos, getLabelTextStyle(), route.getName())
vectorElementVector.add(markerText)
}
routesVectorDataSource.addAll(vectorElementVector)
}
And It's working quite nice so far, since I added the anchorPointY property so the Text objects are at a certain distance from the markers:
textStyleBuilder.anchorPointY = 2.5f
However, long lines produce an undesired effect. They don't get wrapped. So if the line is pretty long...well, it'll show in a single line over the map. It'd be really nice if we could add some property to control the width of the Text objects. Perhaps, it's already available and I wasn't able to find it?
Cheers
Correct, specifying max text width is currently not available. I am tagging this as 'idea maybe future' and we may include this even in 4.2.1 release.
There is a workaround for this, though. You could do text splitting yourself and use '\n' to break lines. In order for this to work properly you need to set TextStyleBuilder.isBreakLines
flag to true.