際際滷

際際滷Share a Scribd company logo
Building Location-Aware Apps 
with Open Source & Open Data 
Chuck Greb | 11揃18揃2014 | AnDevCon
Mapzen is an open source mapping lab 
building and supporting open data and 
software to promote a healthy mapping 
ecosystem.
start where you are
Agenda 
Hour 1: Overview 
 Location-aware apps 
 Open source 
 Open data 
Hour 2: Rendering 
 Raster tiles 
 Vector tiles 
Hour 3: Search & Navigation 
 Location services 
 Geocoding 
 Routing
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
start where you are
Building Location-Aware Apps 
with Open Source & Open Data
Location-Aware Apps 
3 kinds of location-aware apps 
 Mapping applications 
 Location-based apps 
 Apps with location-aware features
Mapping applications
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Location-based apps
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Apps with location-aware features
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Location-Aware Apps 
Common features 
 Maps 
 Geolocation 
 Geocoding 
 Reverse geocoding 
 Search 
 Navigation
Building Location-Aware Apps 
with Open Source & Open Data
Philosophy 
Open Source
Code 
Open Source
License 
Open Source
Community 
Open Source
Open Source 
Advantages 
 Transparency 
 Flexibility 
 Compatibility 
 Free!
Open Source 
Open source is not free like beer
Open Source 
Open source is free like a puppy
Building Location-Aware Apps 
with Open Source & Open Data
Availability & Access 
Open Data
Reuse & Redistribution 
Open Data
Universal participation 
Open Data
Open Knowledge Foundation 
https://okfn.org/ 
Open Data
Building Location-Aware Apps 
with Open Source & Open Data
Open Location Applications 
Components
Open Location Applications 
Datasource
Open Location Applications 
Vector Tiles
Open Location Applications 
Renderer
Open Location Applications 
Location Services 
GPS, WiFi, Network, Sensors, BLE
Open Location Applications 
Geocoder
Open Location Applications 
Search Engine
Open Location Applications 
Route Engine
OpenStreetMap (OSM)
OpenStreetMap (OSM) 
 Crowdsourced Data 
皙 Local knowledge 
皙 Community driven 
 Public Data 
皙 2007 TIGER import 
皙 Manual import process 
 Open Data Commons Open Database License (ODbL) 
皙 Attribution 
皙 Share-Alike 
皙 Keep Open
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
osmdroid
2008 
osmdroid
osmdroid 
Based on Google Maps API v1
osmdroid 
Support for online and offline tile source
osmdroid 
Icons, tracking, and shapes
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Mapbox
Fork of osmdroid 
Mapbox
Mapbox 
Easy integration with Mapbox tile server
Mapbox 
<com.mapbox.mapboxsdk.views.MapView 
android:id="@+id/mapview" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
mapbox:mapid="Your Mapbox mapid" />
Mapbox 
MapView mapView = new MapView(this, "Your Mapbox mapid"); 
this.setContentView(mapView);
(Alternate tile servers also supported) 
Mapbox
Mapbox 
Custom styles & satellite imagery
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
OpenScienceMap
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" 
android:layout_width="match_parent" 
android:layout_height="match_parent" />
OpenScienceMap 
public class MyActivity extends MapActivity { 
... 
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 = getMap().setBaseMap(tileSource); 
getMap().layers().add(new BuildingLayer(getMap(), baseLayer)); 
getMap().layers().add(new PoiLayer(getMap(), baseLayer)); 
getMap().layers().add(new LabelLayer(getMap(), baseLayer)); 
baseLayer.setRenderTheme(ThemeLoader.load( 
AssetAdapter.g.openFileAsStream("styles/map.xml)"))); 
}
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Pelias
modular open-source geocoder 
Pelias
ElasticSearch 
Pelias
OSM 
Geoanmes 
Quattroshapes 
Pelias
Pelias Android SDK 
Pelias
Pelias 
Pelias.getPelias().suggest("Empire State Build", 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
On the Road 
Routing and Navigation
OSRM 
On the Road
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();
On the Road 
Features 
 Navigation 
 Snap to location 
 Calculate distances 
 Reroute
Location Open Source Tracker 
(LOST)
Drop-in replacement for 
FusedLocationProvider 
LOST
talks directly to LocationManager 
LOST
GPS 
Wi-Fi 
Cell Network 
LOST
Frequency 
Accuracy 
Battery Life 
LOST
Replay GPX trace file 
LOST
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 
} 
}); 
}
Speakerbox
Speakerbox 
Features 
 Text-to-Speech 
 Initialization/Shutdown 
 Mute/Unmute 
 Remix!
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Open by Mapzen 
OpenScienceMap Pelias 
VTM Android SDK On the Road LOST 
Speakerbox 
Location TTS 
Pelias OSRM Manager 
Mapzen 
Vector Tile 
Service 
OpenGL ES
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
start where you are
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Break.
osmdroid 
Exercise #1
OpenScienceMap 
Exercise #2
Break.
OpenScienceMap + LOST 
Exercise #3
OpenScienceMap + LOST + Pelias 
Exercise #4
OpenScienceMap + LOST + Pelias + On the Road 
Exercise #5
thanks 
Chuck Greb | @ecgreb 
github.com/mapzen

More Related Content

Building Location-Aware Apps using Open Source (AnDevCon SF 2014)