Creating a custom application

We are now going to create a custom map application. When we tap anywhere on a map, a dialog is shown, which takes text for Title and Snippet for a marker as input. The marker is placed on the clicked location along with an information window.

We can add as many markers as we need and remove a marker by tapping on the information window. Let's proceed!

Our activity layout code is the same as the one we've used before:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.MapFragment" />

activity_maps.xml

Next, we need to create a custom ...

Get Learning Android Google Maps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.