Presentation is loading. Please wait.

Presentation is loading. Please wait.

AnDroid GoogleMaps API

Similar presentations


Presentation on theme: "AnDroid GoogleMaps API"— Presentation transcript:

1 AnDroid GoogleMaps API

2 Agenda Maps API Some Examples Classes Example Application MapActivity
MapView MapController Overlay MyLocationOverlay OverlayController Point TouchGestureDetector TrackballGestureDetector Example Application

3 Maps API Optional Functionality Not necessary May not be supported
Android is an open cell phone platform Google software is not a device requirement Functionality Google Maps is a good example of the Core Features Some features are specific to mobile devices GPS location services not necessary, unlike the activity and the intent APIs. handset may not support it. This API is a Google API, and since Android is an open cell phone platform, there is no requirement for the device to include any Google software. Google Maps can be accessed online maps.google.com to view the basic functionality of this API Most of the features provided with Google maps for desktop web applications are also available for the mobile version. It also includes extra functionality that is specific to mobile devices such as GPS location services

4 Some Examples WikiMapia Panoramio Mashups
Google Calendar mashed with Google Maps Trulia (Real estate website) WikiMapia combines Google maps and a wiki allowing users to add information about any place on earth. The idea is that of “describing the whole planet Earth”. Anyone can contribute since it is a wiki Panoramio (in picture) Similar to wikimapia; people put and share photos of places they’ve visited, placing them in the location on the map. Mash up examples Google Calendar + Google maps = select location on the map and add a calendar with events taking place at the location. (e.g.. At a nightclubs location one can add events that will take place there) Trulia It is a real estate website uses data from their site and mashes with Google maps. Anything that has anything to do with location is good for a mash up with the Google maps API.

5 Classes MapActivity MapView Base class Application extends MapActivity
Provides basic functionalities such as lifecycle management MapView Extends the View class Displays map Provides basic functionality MapActivity = base class of any activity using Maps API. Therefore second point. Third point means users don’t need to provide those functionalities. The View class is used to provide the user interface. A View could be a textbox, menu items or as in this case the container of the map. basic functionality = displaying, capturing key presses, pan and zoom. This functionality can be changed programmatically. Explain code. Default display mode = map View (not satellite view). Changed using mv.toggleSatellite(); The user can move around by dragging the map using the mouse, or using your finger on touch screen devices. Double clicking will center the map on the point where the user clicked. mv.getZoomLevel() gets the zoomLevel that the map is at currently

6 Classes MapController Provides control functionality
Positioning Panning Zooming Handling key events MapView instance can return a MapController using MapController mc = mv.getController(); Panning: 1) centreMapTo(point,true); jumps straight to the point specified. 2) animateTo(point); animates the map to the specified point. mc.zoomTo(zoomLevel); where zoomLevel is a variable of type integer (the uniform zoom level is 18, certain locations have higher zoom levels). Use this method to zoom in or out by first getting the current zoom level using MapView then incrementing or decrementing that level. mc.setFollowMyLocation(true); = follow the devices location on the map as the user travels

7 Classes Overlay MyLocationOverlay OverlayController
Abstract base class Overlay.PixelCalculator Converts latitude, longitude into on-screen pixel coordinates. MyLocationOverlay User’s location on map OverlayController Manages overlays To change pieces of the maps, or add data/images to the map, we use overlays. An overlay = a layer that we can add on top of the map. (Point out overlays on picture) Allows us to add data such as markers, polylines and streets to the static map. To create an overlay, we must create a class that implements the abstract overlay class. Overlay.PixelCalculater is an important class since it obtains information about the map such as height and width and so that the overlay’s size can be matched to the map. User’s location on the map is therefore also an overlay and when it is active it will be requesting constant repaints. In order to use overlays, we use the OverlayController class: oc = mv.createOverlayController(); This controller allows us to add, activate, deactivate an overlay to the map

8 Classes Point TouchGestureDetector TrackballGestureDetector
Specifies a point on the map expressed as Latitude and Longitude TouchGestureDetector Provides methods for obtaining information about motion gestures detected Detects scroll, tap and doubleTap TrackballGestureDetector Latitude and longitude values are kept as integer numbers of micro degrees. TouchGestureDetector analyzes a series of motions and detects gestures. Right now only detects scroll, tap and double tap. Returns information about these gestures such as where you tapped. TrackballGestureDetector provides the same functionality but this time to be used with a trackball instead of a touch screen.

9 Example Application Small example application that uses the maps API for android. Loads the MapView and when the user presses the U key it centers the map to the University of Malta as shown in the screenshot. Explain code.

10 Thank You! Any Questions?


Download ppt "AnDroid GoogleMaps API"

Similar presentations


Ads by Google