What’s the deal with Android maps? 
11.19.2014 | Chuck Greb | @ecgreb
Mapzen is an open source mapping lab building 
and supporting open data and software to 
promote a healthy mapping ecosystem.
start where you are
Cross-platform frameworks 
Issues 
⇢ Look & feel 
⇢ Performance 
⇢ System level integration 
⇢ Inter-app communication 
Just make a mobile web app!
Android Development 101 
(for mappers)
Android Development 101 
Anatomy of an application 
⇢ AndroidManifest 
⬝ Package name 
⬝ Components 
⬝ Permissions 
⬝ Minimum SDK 
⇢ Activities 
⇢ Fragments 
⇢ Views 
⇢ Resources
Android Development 101 
Development Environment 
Google (2008) Community Google (2014) 
Build System Ant Maven Gradle 
IDE Eclipse IntelliJ IDEA Android Studio 
Testing Android Testing 
Framework 
Robolectric Espresso 
Emulator Android Virtual 
Device (ARM) 
Genymotion Android Virtual 
Device (x86)
Android Development 101 
Gradle 
⇢ Groovy (DSL) 
⇢ Build, test, and publish apps 
⇢ Manage distributed dependencies
Android Development 101 
Android Studio 
⇢ Based on IntelliJ IDEA 
⇢ Rich layout editor 
⇢ Tight integration with Android SDK and Gradle
Open Source Map Tools for Android
Open Source Map Tools 
Rendering 
⇢ osmdroid 
⇢ Mapbox 
⇢ OpenScienceMap
Open Source Map Tools 
Geolocation, search & routing 
⇢ LOST 
⇢ Pelias 
⇢ On the Road
osmdroid 
raster tiles
2008 
osmdroid
Based on Google Maps API v1 
osmdroid
osmdroid 
Support for online and offline tile sources
Icons, tracking, and shapes 
osmdroid
osmdroid 
<org.osmdroid.views.MapView 
android:id="@+id/map_view" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tilesource="Mapnik" />
osmdroid 
MapView mapView = new MapView(this, 256); 
this.setContentView(mapView); 
OnlineTileSourceBase mapnikTileSource = new XYTileSource("Mapnik", 
ResourceProxy.string.mapnik, 0, 18, 256, ".png", new String[] { 
"http://a.tile.openstreetmap.org/", 
"http://b.tile.openstreetmap.org/", 
"http://c.tile.openstreetmap.org/" }); 
mapView.setTileSource(mapnikTileSource);
Mapbox 
raster tiles (vector coming soon?)
Fork of osmdroid 
Mapbox
Mapbox 
Easy integration with Mapbox tile server
Mapbox 
<com.mapbox.mapboxsdk.views.MapView 
android:id="@+id/map_view" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
mapbox:mapid="Your Mapbox mapid" />
Mapbox 
MapView mapView = new MapView(this, "Your Mapbox mapid"); 
this.setContentView(mapView);
OpenScienceMap 
vector tiles
OpenScienceMap 
Universität Bremen
OpenScienceMap 
“OpenScienceMap provides free and open maps for Android 
with the fastest and 100% pure vector maps around.”
OpenScienceMap 
<org.oscim.android.MapView 
android:id="@+id/map_view" 
android:layout_width="match_parent" 
android:layout_height="match_parent" />
OpenScienceMap 
public class MyActivity extends MapActivity { 
@Override 
public void onCreate(Bundle icicle) { 
super.onCreate(icicle); 
... 
} 
public Map getMap() { 
return super.map(); 
} 
}
OpenScienceMap 
@Override 
public void onCreate(Bundle icicle) { 
super.onCreate(icicle); 
UrlTileSource tileSource = new OSciMap4TileSource("http://vector.example.com/all"); 
VectorTileLayer baseLayer = map().setBaseMap(tileSource); 
map().layers().add(new BuildingLayer(map(), baseLayer)); 
map().layers().add(new PoiLayer(map(), baseLayer)); 
map().layers().add(new LabelLayer(map(), baseLayer)); 
baseLayer.setRenderTheme(ThemeLoader.load( 
AssetAdapter.g.openFileAsStream("styles/map.xml)"))); 
}
Location Open Source Tracker (LOST) 
location services
Drop-in replacement for LocationClient 
(Google Play Services) 
LOST
talks directly to LocationManager 
(AOSP) 
LOST
LOST 
Location Providers 
⇢ GPS 
⇢ Wi-Fi 
⇢ Cell network 
⇢ Passive
Fused Location Provider 
LOST
LOST 
Optimizations 
⇢ Frequency 
⇢ Accuracy 
⇢ Battery life
LOST 
Debugging features 
⇢ Mock locations 
⇢ Replay GPX trace file
LOST 
LocationClient locationClient = new LocationClient(context, 
new LocationClient.ConnectionCallbacks() { 
@Override public void onConnected(Bundle bundle) { 
onLocationClientConnected(); 
} 
@Override public void onDisconnected() { 
onLocationClientDisconnected(); 
} 
});
LOST 
private void onLocationClientConnected() { 
Location lastLocation = locationClient.getLastLocation(); 
if (lastLocation != null) { 
// do stuff 
} 
LocationRequest locationRequest = LocationRequest.create(); 
locationRequest.setInterval(5000); 
locationClient.requestLocationUpdates(locationRequest, 
new LocationListener() { 
@Override public void onLocationChanged(Location location) { 
// do more stuff 
} 
}); 
}
Pelias 
modular open source geocoder
Pelias 
distributed full-text geographic search engine
Pelias
Pelias 
Datasources 
⇢ OSM 
⇢ Geonames 
⇢ Quattroshapes
Pelias Android SDK 
Pelias
Pelias 
Pelias.getPelias().suggest("Empire State", Callback<Result>); 
Pelias.getPelias().search("Empire State Building", "x1,y1,x2,y2", Callback<Result>);
Pelias 
{ "type": "FeatureCollection", 
"features": [{ 
"type": "Feature", 
"geometry": { 
"type": "Point", 
"coordinates": [ -73.98597, 40.74871 ]}, 
"properties": { 
"text": "Empire State Building, New York County, New York", 
"score": 1, 
"type": "geoname", 
"id": "5116597" 
} 
}, ... 
}
On the Road 
routing and navigation
On the Road
On the Road 
Features 
⇢ Navigation 
⇢ Snap to route 
⇢ Calculate distances 
⇢ Reroute
On the Road 
Router.getRouter().setEndpoint("http://osrm.example.com") 
.setDriving() 
.setLocation(new double[]{lat, lng}) 
.setLocation(new double[]{lat, lng}) 
.setCallback(new Callback() { 
@Override 
public void success(Route route) { 
// do stuff 
} 
@Override 
public void failure(int statusCode) { 
// do stuff 
} 
}).fetch();
Open by Mapzen 
OpenScienceMap Pelias 
VTM Android SDK On the Road LOST 
Speakerbox 
Location TTS 
Pelias OSRM Manager Vector Tile 
Service OpenGL ES
start where you are
Exercise #1 
Hello Android!
Exercise #2 
Raster maps with osmdroid
Exercise #3 
Vector maps with OpenScienceMap
thanks 
11.19.2014 | Chuck Greb | @ecgreb 
github.com/mapzen 
github.com/pelias 
github.com/ecgreb

What's the deal with Android maps?