Introduction
Let's build a simple Map application that will contain the source and destination addresses in the form of fields From and To respectively.
This application will take two user inputs for the map, i.e., Latitude and Longitude. Clicking on the open in the map will open the map that can show you the direction from the current location to the given address defined by the two user inputs.
This application will show you how to open the map without giving any application key. You don't need to generate an API key for this application.
We are opening the map intent from android.net.Uri. Immutable URI reference.
Implementation
- Open the Visual Studio Community edition and select Android App as below.

- Give the app name and click on "Next".

- Give the project and solution name and create the project.

The directory structure will be as follows.

Note
You may have to add the NewtonSoft.Json package for working on JSON serialize and deserialize objects.
Add the following file under the Model directory.
- using System;
- namespace GoogleMapDemo.Model
- {
- public class Navigate
- {
- public string latitude { get; set; }
- public string longitude { get; set; }
- }
- }
Add the following content on main.axml.
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="20dp"
- android:paddingLeft="8dp"
- android:paddingRight="8dp">
- <EditText
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_height="wrap_content"
- android:id="@+id/latitude"
- android:layout_marginBottom="15dp"
- android:hint="@string/latitude" />
- <EditText
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_height="wrap_content"
- android:id="@+id/longitude"
- android:layout_marginTop="10dp"
- android:hint="@string/longitude" />
- <Button
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_height="wrap_content"
- android:id="@+id/open_map_button"
- android:text="@string/open_map" />
- </LinearLayout>
Add the follwoing content on string.xml.
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <string name="app_name">GoogleMapDemo</string>
- <string name="latitude">latitude</string>
- <string name="longitude">longitude</string>
- <string name="open_map">Open in Map</string>
- </resources>




Join the conversation! Your thoughts help the community grow.