Tutorial 3 — Lines
You can view the complete source for this tutorial here: https://github.com/ba3llc/AltusMappingEngineAndroid/tree/master/Lines
In this tutorial, we will build on the previous tutorial and add a vector line to represent a route over a street map. For this, we will:
- Add a dynamic vector map layer on top of the street map.
- Add a stylized line to the dynamic vector map to represent the route.
- Make the vector layer semi-transparent so we can see the map underneath.
- Add markers to the route end-points.
- Automatically zoom in on the route.
Step 1 - Create some route points
Create a helper function to create an array of points to represent the route. These are for a route around Raleigh, NC. But you can use whatever coordinates you want.
Step 2 - Move the marker creation code into another function
Note that we’re changing the zOrder has changed to 3. In the Markers tutorial it was 2. We set it to 3 so we can put it above the vector line we’re going to add.
Step 3 - Create Vector Layer
Just after you load the street map add this code to add a dynamic vector map at zOrder 2. We set the alpha so that the layer will be semi-transparent.
Step 4 - Create a Line Style
Step 5 - Load the route and add a line
Step 6 - Add the markers and zoom to the route
Here we add markers to the route end-points and “look” at the route by specifying its min/max points to the lookAtCoordinates function and give it a 150 point buffer.