With the highly anticipated v2 update of Google Maps for Android we made a big leap forward, with just a couple of steps back. We will show you what has changed, what new problems arose and how Android Maps Extensions helped us solve them.
2. Android Maps v2
Android Maps v2 (end of 2012.)
●
no more extending MapActivity
●
simpler way to add markers (no more extending ItemizedOverlay)
●
fine tuning: position, anchor, color, icon, snippet, title, etc
https://developers.google.com/maps/documentation/android/marker
#add_a_marker
7. App requirements
●
Add a marker for each poi
●
Show different icon (selected) in marker's onClick event
(change icon)
●
Display full poi information (get poi object for selected
marker)
●
Remove marker from map (get marker from the map for
a specific poi)
8. Problems
●
Cannot change properties of an existing marker
– remove the marker and add a new one
– until Google play services rev.7
●
Marker has no knowledge of its poi
– store KV pairs in an arbitrary structure
– getId() method (unreilable), setId(Object value) non existent
– cannot get a marker on the map by an id
●
Cannot extend the Marker class
– public final class Marker
12. Prerequisites
●
Maven Central repo (added three weeks ago)
– dependencies {
– compile 'com.google.android.gms:play-services:4.0.30'
– compile 'com.androidmapsextensions:android-maps-
extensions:2.0+'
}
●
External library for Eclipse projects
13. Google Maps Android API Utility
Library
●
Enables advaced features
– Customization of markers via bubble icons
– Markers are more like info windows
– Markers can be styled
– Cluster manager
– PolyUtil for converting polylines and polygons to latlng
– Enabled interoperability with Google Maps API web services
– SphericalUtil for computation of distances, areas and
headings base on latitudes and longitudes
14. Links
●
Intro to Android Google Maps
– https://developers.google.com/maps/documentation/android/intro
●
Old maps reference
– https://developers.google.com/maps/documentation/android/v1/hello-ma
pview?hl=en
●
Android maps extenstions
– https://code.google.com/p/android-maps-extensions/
●
Android maps utils library
– http://googlemaps.github.io/android-maps-utils/