Display maps
In this section, we are going to learn how to display a desired location in Google Maps. Here, we need to use the keyword geo
along with the coordinates that should be displayed in the map. Let's test this with an example.
Our main layout consists of only a single button, which helps us launch Google Maps. The code is as follows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical"> <Button android:id="@+id/btn" android:text="Display in Google map" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>
activity_maps.xml
Our activity contains the code to handle the click button. It checks whether Google Maps exists. If it exists, it will launch the application. The code is as follows:
package com.raj.map; import android.app.Activity...