March 8, 2016

Google Map is one of the concept which is frequently used in our application. Since it is a vast topic, I’m going to explain all in a set of tutorials. In those tutorials there will be an explanation from simple Map loading to covering all the features of the Google Map. In this tutorial I’m going to show you how to load a basic MAP in your application.

STEP 1: Open your Android Studio, Create a new Project, and select GoogleMapActivity.
STEP 2: It will create three by default files, MapsActivity, the other is the activity_map.xml, and the last one is google_maps_api.xml.



    paste your code here


// This is the activity file where all the functionalities are to be done.

package com.mapstutorial;
import android.os.Bundle;
// This class will implement OnMapReadyCallback
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
    // Take a reference of Google Map
    private GoogleMap googleMap;
    // provide the latitude and the longitude
    private double latitude = 12.850800;
    private double longitude = 77.676623;
    protected void onCreate(Bundle savedInstanceState) {
        // We will use here SupportMapFragment
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
    public void onMapReady(GoogleMap googleMap) {
        this.googleMap = googleMap;
        LatLng latLng = new LatLng(latitude, longitude);
        // MarkerOptions will point the icon to the given location(Latitude and Longitude)
        this.googleMap.addMarker(new MarkerOptions().position(latLng).title("Bangalore"));
        // Camera will move to the pointed location, we can play with the camera option.



It will contain one attribute as android:name=””, this will automatically attach the Map in the activity, however through coding part also it can be done.

This will load a map with a marker pointing at Bangalore. I’ll explain you the code here.
1. The class will implements OnMapReadyCallBack
2. This interface has one method named onMapReady(GoogleMap googleMap).
3. This is the basic map loading. We can change here anything as per our requirement.
4. We will provide the latitude and the longitude.
5. Camera will point to the mentioned position, we will use MarkerOptions to point the latitude and the longitude.
6. We will use CameraUpdateFactory to view the location.
7. getMapAsync() it is used to set the callback of the fragment.

This will load a basic map in your application. However this is the basic simple loading of a map, its just a starting. From next tutorial we will explore more.