Polaris: simple mapping library for Android

Polaris: simple mapping library for Android

Introduction to Polaris, a library greatly enhancing the features of the Google Maps external library with effortless map annotating, gesture support, map callout support, built-in “user tracking” mode, etc.

Source code: https://github.com/cyrilmottier/Polaris
Sample application: https://play.google.com/store/apps/details?id=com.cyrilmottier.android.polarissample
Blog post: http://android.cyrilmottier.com/?p=824

Presented at the Paris Android Use Group in Paris, France.

E9bf8f6d5480ea2a2623df7dccfd1f70?s=128

Cyril Mottier

November 13, 2012
Tweet

Transcript

  1. 3.
  2. 5.
  3. 6.
  4. 7.

    private static class MyOverlay extends ItemizedOverlay<OverlayItem> { 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(); } }
  5. 9.
  6. 10.

    @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ... mMyLocationOverlay

    = new MyLocationOverlay(this, mMapView); mMapView.getOverlays().add(mMyLocationOverlay); }
  7. 11.

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

    void onStop() { mMyLocationOverlay.disableMyLocation(); super.onStop(); }
  8. 12.
  9. 13.

    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
  10. 14.
  11. 16.

    Good luck ! For the callout ... callout layout, background

    image, onTap on marker, callout offset, onTap on map, onClick on callout, etc.
  12. 21.
  13. 24.

    2 Import the Polaris Android project library in your own

    project http://developer.android.com/tools/projects/ projects-eclipse.html#ReferencingLibraryProject
  14. 25.

    3 Bind onStart() and onStop() to PolarisMapView @Override protected void

    onStart() { super.onStart(); mPolarisMapView.onStart(); } @Override protected void onStop() { super.onStop(); mPolarisMapView.onStop(); }
  15. 26.

    2 Import the Polaris Android project library in your own

    project 3 1 Clone the repository Bind onStart() and onStop() to PolarisMapView
  16. 32.

    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
  17. 37.

    @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
  18. 39.