Page 61

Android Programming Cookbook

import import import import

java.util.HashMap; java.util.Iterator; java.util.Map; java.util.Map.Entry;

import import import import

android.os.Bundle; android.support.v4.app.FragmentActivity; android.view.View; android.widget.Toast;

import import import import import import import import import import

com.google.android.gms.maps.CameraUpdate; com.google.android.gms.maps.CameraUpdateFactory; com.google.android.gms.maps.GoogleMap; com.google.android.gms.maps.SupportMapFragment; com.google.android.gms.maps.model.BitmapDescriptorFactory; com.google.android.gms.maps.model.LatLng; com.google.android.gms.maps.model.LatLngBounds; com.google.android.gms.maps.model.Marker; com.google.android.gms.maps.model.MarkerOptions; com.javacodegeeks.androidgooglemapsexample.LatLngInterpolator.LinearFixed;

public class AndroidGoogleMapsActivity extends FragmentActivity { // Google Map private GoogleMap googleMap; private HashMap markersHashMap; private Iterator<Entry> iter; private CameraUpdate cu; private CustomMarker customMarkerOne, customMarkerTwo; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { // Loading map initilizeMap(); initializeUiSettings(); initializeMapLocationSettings(); initializeMapTraffic(); initializeMapType(); initializeMapViewSettings(); } catch (Exception e) { e.printStackTrace(); } } @Override protected void onResume() { super.onResume(); // initilizeMap(); } private void initilizeMap() { googleMap = ((SupportMapFragment) getSupportFragmentManager(). â&#x2020;?findFragmentById(R.id.mapFragment)).getMap(); // check if map is created successfully or not if (googleMap == null) {

53 / 143

SKY MAGZ  

This is Yahya Christian School Magazine

Read more
Read more
Similar to
Popular now
Just for you