iOS API Tutorials
Tutorial 6 — Raster Map Tiles
Displaying tiles (e.g. from MapBox, OSM, MapQuest, etc.) in the BA3 Altus Mapping Engine
In the prior tutorials, we have been using a default low-resolution base map bundled with the app. In this tutorial we will use tiles from a tile provider that are streamed in from the Internet. We will use MapBox tiles in this case, but the BA3 Altus Mapping Engine™ is happy to use tiles from a wide variety of tile providers including MapQuest, OSM, Stamen, etc.
Step 1
We are going to start here by checking out tutorial6:
git reset --hard
git checkout tutorial6
The reason we need to do this is because the project now contains six new files in the project's Internet Maps directory. These six files (three .h and three .m files) implement a tile provider, a tile cache, and then provide the tiles to the mapping engine on request.
Step 2
Run the app. Leave the GPS off for the moment and note the new "SM" button. This button turns on a new map layer that displays MapBox tiles. Tap the SM button and the MapBox tiles will appear. Pan and Zoom and you will be able to see the tiles streaming in.
Now click the GPS button to turn the GPS on. In the iOS Simulator menu bar, choose the Debug menu and then choose the Location item. Choose one of the options that show motion, like "Freeway Drive" or "City Bicycle Ride". Look in the console window of Xcode and you will see the speed and course changing. The map should pan to the new location so that the new location is centered on the screen and rotate the map to demonstrate Track-Up mode if you click the buttons to turn on the GPS and turn on Track-Up. The marker should appear and disappear when you tap the GPS button.
If you zoom all the way in and activate the "Freeway Drive", you can see the marker driving down the freeway. The map will pan automatically.
Step 3
If you look in the MEInternetTileProvider.m file, you will see that there are functions there for several tile providers, including:
- MEMapBoxLandCoverTileProvider
- MEMapQuestTileProvider
- MEMapQuestAerialTileProvider
- MEStamenTerrainTileProvider
- MEOpenStreetMapsTileProvider
To try these out in a crude/simple way, look for the createTileProvider function at the very bottom of the MEInternetMaps.m file. You should see a function that looks like this:
All of this functionality is described in the Documentation, but let's look at what is happening here because it is pretty straightforward.
In that function, try replacing the word MEMapBoxLandCoverTileProvider with any of the other words from the list, for example MEMapQuestAerialTileProvider. Rebuild the app and run it.
In Tutorial 7, we will look at the steps you can take to load a new tile provider in the BA3 Altus Mapping Engine™, using MapBox's LandSat data as an example.
You can learn more about the Altus Mapping Engine™ classes used in this tutorial in the Documentation. If you have any questions about the Altus Mapping Engine™, any feature requests or suggestions for improving the Altus Mapping Engine™, please send them to [email protected].