New Google Maps Android API

One of the most useful features on today’s smartphones is GPS and mapping software.  When this doesn’t work, it can really hurt the user experience and become unsafe.  This is why I am glad that Google continues strive to improve upon Maps and their Maps API is no different.

With the new Google Play services v2.0, there were updates to a lot of Android features.  These updates included an update to the Maps API.  The new Maps API is now easier to use and includes a number of new features that were not present before.  To achieve some of these features the developer used to have to code their own solution.  One of these features is the 2d and 3d views that allow a user to tilt and rotate with gestures.  The new Maps API now includes a number of indoor maps and there is also support for Map Fragments.  To instantiate the Map Fragment, simply include:

<fragment
android:id=”@+id/map”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
class=“com.google.android.gms.maps.MapFragment” />

Among other new features include the use of Photo Sphere.  If you are unfamiliar with Photo Sphere, it is essentially a way of creating 360 degree panoramas.  These can then have locations attached and shared in Google Maps or Google Earth.  Since Photo Sphere is an open format, anyone can create or view these images on a mobile device.  The example code with the new Maps API to determine if an image is Photo Sphere or not and then open it in the respective application is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// This listener will be called with information about the given panorama.
OnPanoramaInfoLoadedListener infoLoadedListener =
  new OnPanoramaInfoLoadedListener() {
    @Override
    public void onPanoramaInfoLoaded(ConnectionResult result,
                                     Intent viewerIntent) {
        if (result.isSuccess()) {
            // If the intent is not null, the image can be shown as a
            // panorama.
            if (viewerIntent != null) {
                // Use the given intent to start the panorama viewer.
                startActivity(viewerIntent);
            }
        }
       
        // If viewerIntent is null, the image is not a viewable panorama.
    }
};
// Create client instance and connect to it.
PanoramaClient client = ...
...
// Once connected to the client, initiate the asynchronous check on whether
// the image is a viewable panorama.
client.loadPanoramaInfo(infoLoadedListener, panoramaUri);

The new Maps API includes so many new features and made so many tasks easier, I am wishing that this was out earlier for previous map based applications I have worked on.  In the future it will be exciting to use the API and really take advantage of it’s new features.

Have you used the new API, if so what feature do you like the most?

This entry was posted in Applications, Mobile, Technology and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>