Draw and Fly To Polyline
In this guide you will learn how to render an interactive map, draw a polyline on the map and fly to the location of the polyline.
Close-up polyline
Zoomed out polyline
The example draws a polyline on the map and flies to it. Displays an interactive map which is fully 3D, supporting pan, pinch-zoom, rotate and tilt.
In the flyToPolyline()
function:
- A
MarkerCollection
instance is created. - A
Marker
populated with the coordinate pairs defining the polyline's perimeter is added to that collection. - The collection is rendered on the map via
MarkerCollectionRenderSettings
. - The collection’s bounding box is retrieved (
markerCollection.area
). - If the bounding box is non-null, it is passed to
mapView.centerOnArea()
, which animates the camera to frame the entire polyline within the viewport.
MainActivity
overrides onCreate()
which checks that internet access is available, and when the map is initialized, calls the flyToPolyline()
function.