Android Application Development: Google Maps API V2
Android Application Development: Google Maps API V2
With the handle to the GoogleMap object for the MapFragment, we can
set initial options for the map.
Add a Map to App
Google Maps API V2 Add a Fragment [3]
Verify Map Availability:
Before interacting with GoogleMap object, confirm map availability and
Google Play services components are correctly installed on the device.
Add a Map to App
Google Maps API V2 Map Types [1]
1.Normal: Typical road map. Roads, some man-made features, and important
natural features such as rivers are shown. Road and feature labels are also visible.
2.Hybrid: Satellite photograph data with road maps added. Road and feature labels
are also visible.
3. Satellite: Satellite photograph data. Road and feature labels are not visible.
4.Terrain: Topographic data. The map includes colors, contour lines and labels, and
perspective shading. Some roads and labels are also visible.
5.None: No tiles. The map will be rendered as an empty grid with no tiles
loaded.
Add a Map to App
Google Maps API V2 Map Types [2]
• LocationManager lm =getSystemService(LOCATION_SERVICE)
• ADD Criteria
• Accuracy/ ACCURACY_FINE , ACCURACY_COARSE /
• power usage/ POWER_HIGH , POWER_MEDIUM, POWER_LOW/
• LocationManager.requestLocationUpdates(provider, mills, distance,
LocationListner example
LocationManger locationManager=
(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
locationListener=new LocationListener(){
public void onLocationChanged( Location location){
LatLonPoint now=new LatLonPoint(loc.getLatitude(),loc.getLongitude());
}
public void onStatusChanged( String provider, int status, Bundle extras)
{
}
public void onProviderEnabled( String provider){
}
public void onProviderDisabled( String provider){
}
}; locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,0,0,locationListener);
GoogleMap[1]
Nested Classes(Interface)
• GoogleMap.OnCameraChangeListener
• GoogleMap.OnMapClickListener
• GoogleMap.OnMapLongClickListener
• GoogleMap.OnMarkerClickListener
• GoogleMap.OnMarkerDragListener
GoogleMap[2]
• animateCamera(CameraUpdate update)
• setMapType(int type)
• setMyLocationEnabled(boolean enabled)
• setOnCameraChangeListener(
GoogleMap.OnCameraChangeListener listener)
• setOnMapClickListener(GoogleMap.OnMapClickListener listener)
• setOnMarkerClickListener(GoogleMap.OnMarkerClickListener
listener)
GoogleMap[3]
• addCircle(CircleOptions options)
• addGroundOverlay(GroundOverlayOptions options)
• addMarker(MarkerOptions options)
• addPolygon(PolygonOptions options)
• addPolyline(PolylineOptions options)