--ADVERTISEMENT--

In the previous Google Maps Android API Getting Started Tutorial: Part 1 tutorial, we had made new android project with Google Maps Activity, created a key for google map application then ran that to see the google map in our application. Google map allows you to perform lots of customization. In this tutorial, you will learn to make android app to display curse in current location using Google Map Android API V2.

Many corporate android apps make a page like contact us, about us and they display company location by highlighting actual company using google map.

Related:
Android Chrome Custom Tabs Android Tutorial with Example
YouTube Android API Integration: Getting Started with YouTube Android API
How to Get Current GPS Location Programmatically in Android

Android Example: How to Display Specific Location in Google Map using V2 API


If you are directly in this tutorial I recommend you to follow Google Maps Android API Getting Started Tutorial: Part 1 before going through this because this is continuous tutorial after that.

Android Example: How to Display Specific Location in Google Map using V2 API

In the previous tutorial we had displayed default google map in android application and here we will customize little bit and add map cursor to our location and add some text.

Open your MapsActivity.java file of Google Maps Android API project and add a line of java code mMap.setMyLocationEnabled(true); under onMapReady method. Change the line LatLng sydney = new LatLng(27.746974, 85.301582); with your location latitude and longitude. Replace 27.746974 with your latitude and 85.301582 with longitude. In this tutorial, I have used the latitude of Kathmandu, Nepal you can use your own. MapsActivity.java file will look like below.

src/MapsActivity.java

All other files are same that as previous. We don’t need to change other files to display current location in google map.

Video Demo


Now run your Get Current Location - Google Maps Android API Tutorial: Part 2 application, you will see a cursor in google map with your current location. If you click on the cursor some texts appears that we place in our java activity file.

What Next: Google Maps Android API Adding Search Bar: Part 3

Download Complete Project

You can download complete example project source code form GitHub.

Post a Comment

Powered by Blogger.