Upload
chuck-greb
View
227
Download
0
Tags:
Embed Size (px)
Citation preview
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
Issues⇢ Look & feel
⇢ Performance
⇢ System level integration
⇢ Inter-app communication
Just make a mobile web app!
Cross-platform frameworks
Android Development 101(for mappers)
Anatomy of an application⇢ AndroidManifest
⬝ Package name
⬝ Components
⬝ Permissions
⬝ Minimum SDK
⇢ Activities
⇢ Fragments
⇢ Views
⇢ Resources
Android Development 101
Development Environment
Android Development 101
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)
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
Android Development 101
Open Source Map Tools for Android
Rendering⇢ osmdroid
⇢ Mapbox
⇢ OpenScienceMap
Open Source Map Tools
Geolocation, search & routing⇢ LOST
⇢ Pelias
⇢ On the Road
Open Source Map Tools
osmdroidraster tiles
2008
osmdroid
Based on Google Maps API v1
osmdroid
Support for online and offline tile sources
osmdroid
Icons, tracking, and shapes
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);
osmdroid
Mapboxraster tiles (vector coming soon?)
Fork of osmdroid
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);
Mapbox
OpenScienceMapvector tiles
Universität Bremen
OpenScienceMap
“OpenScienceMap provides free and open maps for Androidwith 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)")));
}
OpenScienceMap
Location Open Source Tracker (LOST)location services
Drop-in replacement for LocationClient(Google Play Services)
LOST
talks directly to LocationManager(AOSP)
LOST
Location Providers⇢ GPS
⇢ Wi-Fi
⇢ Cell network
⇢ Passive
LOST
Fused Location Provider
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
}
});
}
LOST
Peliasmodular open source geocoder
distributed full-text geographic search engine
Pelias
Pelias
Datasources⇢ OSM
⇢ Geonames
⇢ Quattroshapes
Pelias
Pelias Android SDK
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"
}
}, ...
}
Pelias
On the Roadrouting and navigation
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();
On the Road
Open by Mapzen
Pelias Android SDK On the Road LOSTOpenScienceMap
VTM Speakerbox
TTSLocationManagerOSRMPeliasVector Tile
Service OpenGL ES
start where you are
Exercise #1Hello Android!
Exercise #2Raster maps with osmdroid
Exercise #3Vector maps with OpenScienceMap
thanksgithub.com/mapzengithub.com/peliasgithub.com/ecgreb
11.19.2014 | Chuck Greb | @ecgreb