I tried getting BoundingBox of route instance and set the polygon over it but the result was a rectangle over the route as shown in the image below which is inappropriate.
Also, I tried to add the BoundingBox of some color with alpha value for transparency over the geocoordinates in the route with a certain distance but the polygons were overlapping and hiding the visibility of Route, like in the image below. Note: (Red circle shows the route which is somewhat visible at certain location due to less overlapping)
I am unable to find any way using which I can merge the multiple polygons into one giant polygon surrounding the route like in 2nd image.
Below is my code which provided me the results in the 2nd image.
fun addBoundingBoxTo(center: GeoCoordinate) {
val boundingBox = GeoBoundingBox(center, 1000f, 1000f)
val coordinates: MutableList<GeoCoordinate> = ArrayList()
coordinates.add(boundingBox.topLeft)
coordinates.add(GeoCoordinate(boundingBox.topLeft.latitude,
boundingBox.bottomRight.longitude,
boundingBox.topLeft.altitude))
coordinates.add(boundingBox.bottomRight)
coordinates.add(GeoCoordinate(boundingBox.bottomRight.latitude,
boundingBox.topLeft.longitude, boundingBox.topLeft.altitude))
val geoPolygon = GeoPolygon(coordinates)
val polygon = MapPolygon(geoPolygon)
polygon.fillColor = Color.parseColor("#77777777")
polygon.lineWidth = 0
map.addMapObject(polygon)
}
route.routeGeometry.forEach {
addBoundingBoxTo(it)
}
The desired result I want to achieve is like in the below image:
Any help would be appreciated. Thanks!