71
What’s the deal with Android maps? 11.19.2014 | Chuck Greb | @ecgreb

What's the deal with Android maps?

Embed Size (px)

Citation preview

Page 1: What's the deal with Android maps?

What’s the deal with Android maps?11.19.2014 | Chuck Greb | @ecgreb

Page 2: What's the deal with Android maps?

Mapzen is an open source mapping lab building and supporting open data and software to promote a healthy mapping ecosystem.

Page 3: What's the deal with Android maps?

start where you are

Page 4: What's the deal with Android maps?
Page 5: What's the deal with Android maps?
Page 6: What's the deal with Android maps?
Page 7: What's the deal with Android maps?
Page 8: What's the deal with Android maps?

Issues⇢ Look & feel

⇢ Performance

⇢ System level integration

⇢ Inter-app communication

Just make a mobile web app!

Cross-platform frameworks

Page 9: What's the deal with Android maps?

Android Development 101(for mappers)

Page 10: What's the deal with Android maps?

Anatomy of an application⇢ AndroidManifest

⬝ Package name

⬝ Components

⬝ Permissions

⬝ Minimum SDK

⇢ Activities

⇢ Fragments

⇢ Views

⇢ Resources

Android Development 101

Page 11: What's the deal with Android maps?
Page 12: What's the deal with Android maps?

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)

Page 13: What's the deal with Android maps?

Gradle⇢ Groovy (DSL)

⇢ Build, test, and publish apps

⇢ Manage distributed dependencies

Android Development 101

Page 14: What's the deal with Android maps?

Android Studio⇢ Based on IntelliJ IDEA

⇢ Rich layout editor

⇢ Tight integration with Android SDK and Gradle

Android Development 101

Page 15: What's the deal with Android maps?
Page 16: What's the deal with Android maps?

Open Source Map Tools for Android

Page 17: What's the deal with Android maps?

Rendering⇢ osmdroid

⇢ Mapbox

⇢ OpenScienceMap

Open Source Map Tools

Page 18: What's the deal with Android maps?

Geolocation, search & routing⇢ LOST

⇢ Pelias

⇢ On the Road

Open Source Map Tools

Page 19: What's the deal with Android maps?

osmdroidraster tiles

Page 20: What's the deal with Android maps?

2008

osmdroid

Page 21: What's the deal with Android maps?

Based on Google Maps API v1

osmdroid

Page 22: What's the deal with Android maps?

Support for online and offline tile sources

osmdroid

Page 23: What's the deal with Android maps?

Icons, tracking, and shapes

osmdroid

Page 24: What's the deal with Android maps?

<org.osmdroid.views.MapView

android:id="@+id/map_view"

android:layout_width="match_parent"

android:layout_height="match_parent"

tilesource="Mapnik" />

osmdroid

Page 25: What's the deal with Android maps?

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

Page 26: What's the deal with Android maps?
Page 27: What's the deal with Android maps?

Mapboxraster tiles (vector coming soon?)

Page 28: What's the deal with Android maps?

Fork of osmdroid

Mapbox

Page 29: What's the deal with Android maps?

Easy integration with Mapbox tile server

Mapbox

Page 30: What's the deal with Android maps?

<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

Page 31: What's the deal with Android maps?

MapView mapView = new MapView(this, "Your Mapbox mapid");

this.setContentView(mapView);

Mapbox

Page 32: What's the deal with Android maps?
Page 33: What's the deal with Android maps?

OpenScienceMapvector tiles

Page 34: What's the deal with Android maps?

Universität Bremen

OpenScienceMap

Page 35: What's the deal with Android maps?

“OpenScienceMap provides free and open maps for Androidwith the fastest and 100% pure vector maps around.”

OpenScienceMap

Page 36: What's the deal with Android maps?

<org.oscim.android.MapView

android:id="@+id/map_view"

android:layout_width="match_parent"

android:layout_height="match_parent" />

OpenScienceMap

Page 37: What's the deal with Android maps?

public class MyActivity extends MapActivity {

@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

...

}

public Map getMap() {

return super.map();

}

}

OpenScienceMap

Page 38: What's the deal with Android maps?

@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

Page 39: What's the deal with Android maps?
Page 40: What's the deal with Android maps?

Location Open Source Tracker (LOST)location services

Page 41: What's the deal with Android maps?

Drop-in replacement for LocationClient(Google Play Services)

LOST

Page 42: What's the deal with Android maps?
Page 43: What's the deal with Android maps?
Page 44: What's the deal with Android maps?

talks directly to LocationManager(AOSP)

LOST

Page 45: What's the deal with Android maps?

Location Providers⇢ GPS

⇢ Wi-Fi

⇢ Cell network

⇢ Passive

LOST

Page 46: What's the deal with Android maps?

Fused Location Provider

LOST

Page 47: What's the deal with Android maps?

Optimizations⇢ Frequency

⇢ Accuracy

⇢ Battery life

LOST

Page 48: What's the deal with Android maps?

Debugging features⇢ Mock locations

⇢ Replay GPX trace file

LOST

Page 49: What's the deal with Android maps?

LocationClient locationClient = new LocationClient(context,

new LocationClient.ConnectionCallbacks() {

@Override public void onConnected(Bundle bundle) {

onLocationClientConnected();

}

@Override public void onDisconnected() {

onLocationClientDisconnected();

}

});

LOST

Page 50: What's the deal with Android maps?

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

Page 51: What's the deal with Android maps?

Peliasmodular open source geocoder

Page 52: What's the deal with Android maps?

distributed full-text geographic search engine

Pelias

Page 53: What's the deal with Android maps?

Pelias

Page 54: What's the deal with Android maps?

Datasources⇢ OSM

⇢ Geonames

⇢ Quattroshapes

Pelias

Page 55: What's the deal with Android maps?

Pelias Android SDK

Pelias

Page 56: What's the deal with Android maps?

Pelias.getPelias().suggest("Empire State", Callback<Result>);

Pelias.getPelias().search("Empire State Building", "x1,y1,x2,y2", Callback<Result>);

Pelias

Page 57: What's the deal with Android maps?

{ "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

Page 58: What's the deal with Android maps?

On the Roadrouting and navigation

Page 59: What's the deal with Android maps?

On the Road

Page 60: What's the deal with Android maps?

Features⇢ Navigation

⇢ Snap to route

⇢ Calculate distances

⇢ Reroute

On the Road

Page 61: What's the deal with Android maps?

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

Page 62: What's the deal with Android maps?
Page 63: What's the deal with Android maps?

Open by Mapzen

Pelias Android SDK On the Road LOSTOpenScienceMap

VTM Speakerbox

TTSLocationManagerOSRMPeliasVector Tile

Service OpenGL ES

Page 64: What's the deal with Android maps?
Page 65: What's the deal with Android maps?
Page 66: What's the deal with Android maps?
Page 67: What's the deal with Android maps?

start where you are

Page 68: What's the deal with Android maps?

Exercise #1Hello Android!

Page 69: What's the deal with Android maps?

Exercise #2Raster maps with osmdroid

Page 70: What's the deal with Android maps?

Exercise #3Vector maps with OpenScienceMap

Page 71: What's the deal with Android maps?

thanksgithub.com/mapzengithub.com/peliasgithub.com/ecgreb

11.19.2014 | Chuck Greb | @ecgreb