0

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.

enter image description here

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)

enter image description here

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:

enter image description here

Any help would be appreciated. Thanks!

mithil1501
  • 506
  • 9
  • 20
  • Can't you just create second polyline with the same coordinates as the Route polyline, but wider? – Tomas Apr 20 '20 at 14:29
  • We want to show the polygon over the region which is some km/miles away. So, the polyline wouldn't work as it would parallel to route line – mithil1501 Apr 23 '20 at 10:20
  • I see. Hmm, that should be also doable. You just get the waypoints of the polyline, move them in one direction, then move them also in the opposite direction, concatenate all those moved waypoints and use them to create new polygon. I am not familiar with the SDK, but I could provide solution using Javascript API if it helped you. – Tomas Apr 23 '20 at 10:56

1 Answers1

0

With the latest December release, can now also specify up to 20 polygons in a routing request. This allows a more precise and simple way to define areas that should be avoided.

lampard
  • 41
  • 5