March 8, 2016

In the previous tutorial we had loaded a basic Map. In this tutorial we will explore more on the Google Map. In the map_activity.xml, we were using SupportMapFragment, and MapFragment is also being used. So what is the difference among them, lets have a discussion for that.

MapFragment is used if you are using the target version above than API 12, but what if you are using below API 12, then the SupportMapFragment comes to rescue.

GoogleMap handles many operations automatically, few of the operations are listed below:
1. Downloading the Map Tiles
2. Connecting to the Google Maps Service
3. Displayiong Tiles on the devices Screen
4. Displaying various controls such as pan and Zoom
5. Zooming in or Out.

For calling the above functionalities, we are not using any additional methods, GoogleMap is handle these all.

MAP TYPES: There are Five types of Map, which runs as follows:

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.


By using this syntax, we can get the desired map type. For example I’m making my Map type as hybrid. googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

While setting up the basic map, we can provide some functionality through the xml or with the code too. First we will try to access some of the features through the xml view.

In this you can find out that I’m providing the latitude, longitude, cameraTarget, zoom feature, may type, scrolling and few more. All were done in the xml file itself. However you can provude it in the progamatic way too. If we do programatically then follow these steps:

First create an object for GoogleMapOptions, like this:

GoogleMapOptions googleMapOptions =  new GoogleMapOptions();

And now, on the refrence we will call various methods like below:


Here in the above code I’m enabling the Compass and making the tilt gesture to be false.
In the next tutorial we will explore more of the in built features of the Google Map.