Day 13: Google Maps Android API V2 Part 3

10
Google Maps API V2 Part 3 Ahsanul Karim [email protected] http://droidtraining.wordpress.com Android Application Development Add Markers Drawing Shapes (Lines, Polygons & Circles)

description

 

Transcript of Day 13: Google Maps Android API V2 Part 3

Page 1: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Part 3

Ahsanul [email protected]

http://droidtraining.wordpress.com

Android Application Development

● Add Markers● Drawing Shapes

(Lines, Polygons & Circles)

Page 2: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Markers [1] 1. Markers identify locations on the map.

2. Markers use a standard icon.

3. It's possible to change the icon's color, image or anchor point via the API.

4. Markers are objects of type Marker, and are added to the map with the GoogleMap.addMarker(markerOptions) method.

5. Markers are designed to be interactive. Markers receive click events, for example, and are often used within event listeners to bring up info windows.

Page 3: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Markers [2] Add a Marker:

Page 4: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Markers [3] Customize a Marker:

Position (Required): The LatLng value for the marker's position on the map. This is the only required property for a Marker object.

Title: A string that's displayed in the info window when the user taps the marker.

Snippet: Additional text that's displayed below the title.

Draggable: Set to true if you want to allow the user to move the marker. Defaults to false.

Visible: Set to false to make the marker invisible. Defaults to true.

Anchor: The point on the image that will be placed at the LatLng position of the marker. This defaults to the middle of the bottom of the image.

Icon: A bitmap that's displayed in place of the default marker image. You can't change the icon once you've created the marker.

Page 5: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Markers [4] Customize a Marker: Changing default Icon

1. fromAsset(String assetName)

2. fromBitmap (Bitmap image)

3. fromFile (String path)

4. fromResource (int resourceId)

Page 6: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Markers [5] Event Handling

The following events can be listened to:1. Marker click events2. Marker drag events3. Info window click events

Page 7: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Shapes The Google Maps API for Android offers some simple ways for us to add shapes to our maps in order to customize them for your application.

● A Polyline is a series of connected line segments that can form any shape you want and can be used to mark paths and routes on the map.

● A Polygon is an enclosed shape that can be used to mark areas on the map.

● A Circle is a geographically accurate projection of a circle on the Earth's surface drawn on the map.

Page 8: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Polylines

Page 9: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Polygons

Circles can also be added similarly

Page 10: Day 13: Google Maps Android API V2  Part 3

Google Maps API V2 Customizing Appearances

Properties:1. Stroke COlor2. Fill Color3. Stroke Width4. Geodesic Segments5. Z-index6. Visibility