Monday, October 26, 2015

Google Maps Android API v2 - initialize map in xml

Example to initialize "com.google.android.gms.maps.SupportMapFragment" in layout xml, to set default cameraTargetLat, cameraTargetLng, cameraZoom, uiZoomControls, mapType, cameraTilt and cameraBearing.

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
    android:layout_height="match_parent" android:id="@+id/map" tools:context=".MapsActivity"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    map:cameraTargetLat="40.689213"
    map:cameraTargetLng="-74.044626"
    map:cameraZoom="20"
    map:uiZoomControls="true"
    map:mapType="satellite"
    map:cameraTilt="80"
    map:cameraBearing="112.5"/>




This video show how to modify last example of "Add Marker to Google Map (Google Maps Android API v2)" to initialize map in layout xmp, layout/activity_maps.xml. In order to demonstrate on screen, I run BlueStacks App Player as Android Emulator.


Next: Detect touch on GoogleMap, onMapClick() and onMapLongClick()

~ Step-by-step of Android Google Maps Activity using Google Maps Android API v2, on Android Studio

No comments: