Slide 1

Slide 1 text

Polaris Simple mapping library for Android

Slide 2

Slide 2 text

@cyrilmottier

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

with Google Maps

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

private static class MyOverlay extends ItemizedOverlay { public MyOverlay(Context context) { super(boundCenterBottom(context .getResources() .getDrawable(R.drawable.map_pin_holed_purple))); } @Override protected OverlayItem createItem(int index) { return sFrance.get(index); } @Override public int size() { return sFrance.size(); } }

Slide 8

Slide 8 text

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); mMapView = (MapView) findViewById(R.id.map_view); mMapView.getOverlays().add(new MyOverlay(this)); }

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ... mMyLocationOverlay = new MyLocationOverlay(this, mMapView); mMapView.getOverlays().add(mMyLocationOverlay); }

Slide 11

Slide 11 text

@Override protected void onStart() { super.onStart(); mMyLocationOverlay.enableMyLocation(); } @Override protected void onStop() { mMyLocationOverlay.disableMyLocation(); super.onStop(); }

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

1 FrameLayout with MapView and a Button 2 Style and position the Button 3 Set an OnClickListener to the Button 4 Get the current position and center on it

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

For the callout ... Good luck !

Slide 16

Slide 16 text

Good luck ! For the callout ... callout layout, background image, onTap on marker, callout offset, onTap on map, onClick on callout, etc.

Slide 17

Slide 17 text

A lot of code for almost nothing

Slide 18

Slide 18 text

with Polaris

Slide 19

Slide 19 text

mPolarisMapView .setAnnotations( sFrance, R.drawable.map_pin_holed_violet) mPolarisMapView .setUserTrackingButtonEnabled(true);

Slide 20

Slide 20 text

Introduction

Slide 21

Slide 21 text

Demo

Slide 22

Slide 22 text

Source code github.com/cyrilmottier/Polaris Introduction http://android.cyrilmottier.com/?p=824 Sample application http://goo.gl/QBvdW

Slide 23

Slide 23 text

1 Clone the repository git clone https://github.com/cyrilmottier/Polaris.git

Slide 24

Slide 24 text

2 Import the Polaris Android project library in your own project http://developer.android.com/tools/projects/ projects-eclipse.html#ReferencingLibraryProject

Slide 25

Slide 25 text

3 Bind onStart() and onStop() to PolarisMapView @Override protected void onStart() { super.onStart(); mPolarisMapView.onStart(); } @Override protected void onStop() { super.onStop(); mPolarisMapView.onStop(); }

Slide 26

Slide 26 text

2 Import the Polaris Android project library in your own project 3 1 Clone the repository Bind onStart() and onStop() to PolarisMapView

Slide 27

Slide 27 text

Feature Overview

Slide 28

Slide 28 text

Gesture support

Slide 29

Slide 29 text

Single tap Gesture support

Slide 30

Slide 30 text

Gesture support Double tap I Single tap

Slide 31

Slide 31 text

Gesture support Double tap I Single tap I Long press

Slide 32

Slide 32 text

mPolarisMapView.setOnMapViewLongClickListener(new OnMapViewLongClickListener() { @Override public void onLongClick(PolarisMapView mapView, GeoPoint geoPoint) { // Do whatever you want with this long click that occurred // at the given GeoPoint } }); OnMapViewLongClickListener

Slide 33

Slide 33 text

Annotations

Slide 34

Slide 34 text

Effortless Annotations

Slide 35

Slide 35 text

Effortless Annotations I Auto callout

Slide 36

Slide 36 text

Effortless Annotations I Auto callout I Variable anchor

Slide 37

Slide 37 text

@Override public void onAnnotationSelected(PolarisMapView mapView, MapCalloutView calloutView, int position, Annotation annotation) { calloutView.setData(annotation); calloutView.setDisclosureEnabled(true); } @Override public void onAnnotationDeselected(PolarisMapView mapView, MapCalloutView calloutView, int position, Annotation annotation) { // Unbind the calloutView from your code } @Override public void onAnnotationClicked(PolarisMapView mapView, MapCalloutView calloutView, int position, Annotation annotation) { startActivity(new Intent(this, AnnotationDetailActivity.class)); } OnAnnotationSelectionChangedListener

Slide 38

Slide 38 text

And others ...

Slide 39

Slide 39 text

Built-in “user tracking” mode Auto built-in zoom controls Natural callouts transitions Additional listeners And others ...

Slide 40

Slide 40 text

More on Polaris

Slide 41

Slide 41 text

MapCalloutView

Slide 42

Slide 42 text

MapCalloutView Title

Slide 43

Slide 43 text

MapCalloutView Title Subtitle

Slide 44

Slide 44 text

MapCalloutView Title Subtitle Disclosure indicator / Right accessory

Slide 45

Slide 45 text

MapCalloutView Title Subtitle Disclosure indicator / Right accessory Left accessory

Slide 46

Slide 46 text

MapCalloutView Disclosure indicator / Right accessory Left accessory You can even use a custom View if you want to

Slide 47

Slide 47 text

Limitations

Slide 48

Slide 48 text

Do NOT use getOverlay() Limitations

Slide 49

Slide 49 text

What’s next?

Slide 50

Slide 50 text

Pre-defined markers New listeners Clustering New gestures And more ... What’s next?

Slide 51

Slide 51 text

Source code

Slide 52

Slide 52 text

@cyrilmottier android.cyrilmottier.com Cyril Mottier