Tutorial 2 — Markers
You can view the source for this tutorial here: https://github.com/ba3llc/AltusMappingEngineAndroid/tree/master/Markers
In this tutorial we will add geographic markers to a map. Marker’s are images that represent points on a map.
The Altus Mapping Engine has an extremely flexible and powerful marker system. It supports pre-generated clustered marker maps, on-device generated clustered marker maps, as well as on-the-fly dynamic marker maps. It supports marker hit-testing, fade-in / fade-out, and a couple of different ways of orienting: screen-aligned or true-north aligned.
For this tutorial, however, we’ll keep it simple. We’ll build on the HelloWorldMap tutorial and add a dynamic marker layer on top of a streaming street-map.
Step 1 - Add a marker image assets to your application
Here, we’re using a couple of simple dot images. Feel free to use your own images. Place them in your applications assets folder.
Step 2 - Load a Street Map
Start with the HelloWorldMap tutorial, and change the map it loads when it starts up to be the MapQuest streetmap:
Note: The default zOrder of this map will be 1. So if we want to put layers on top it, we need to set their zOrder higher than 1. You can change zOrder of layers by using the setMapZorder function.
Step 3 - Import packages
Step 4 - Create an loadBitmap Helper Function
Add a helper function to load a bitmap from your application’s assets.
Step 5 - Add a Dynamic Marker Map Layer and a Marker
In your activity's onCreate function, just after you add the map, create a marker may layer, add it, then add a marker to it. You can set the location to any coordinate you want. In this example, the location is Raleigh, NC:
Step 6 - Run your application
Run your application and pan / zoom over to Raleigh, NC. You should see a marker on the map at the coordinates you specified.
Notes and Things to Try
Dynamic marker layers allow you to move and reposition markers, either instantaneously, or with a smooth animation to a new location. You can also rotate markers instantaneously, or with animation.
Try creating a vehicle marker with animated movement and rotation. You’ll use these functions: