Read More
Read now

Displaying Maps to power location experiences

Save

In the mobile applications world, one idea that is implemented in a very good way is the use of maps and the location-based applications, that help us in multiple ways in our everyday life. particularly store location.

Google provides via Google Play Services a library for using maps. Maps allow users to explore the world more clearly and let them identify locations with custom markers and much more.

1. Setup for Implementing Google Map

To use Google Maps, set up the Google Play services SDK in your app development project.

compile ‘com.google.android.gms:play-services:6.5.87’

1.1 Create a Google Maps API key for Android

To access the Google Maps tools, you need an API key, which you can obtain through a Google account. The key is based on your Android app debug or release certificate. More information can be found on following links:

https://console.developers.google.com/

https://developers.google.com/maps/documentation/android-api

1.2 Add permissions and metadata to the Manifest

We need to add a feature element for OpenGL ES version 2:

add metadata for google API:

2. Implementaion

2.1  MapFragment

The MapFragment class extends the Fragment class and provides the life cycle management and the services for displaying aGoogleMap widget. GoogleMap is the class which shows the map. The MapFragment has the getMap() method to access this class.

googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

2.2  Example Activity

2.3 Adding Marker

We can create markers on the map via the Marker class. This class can be highly customized. On GoogleMap we can register a listener for the markers in our map via thesetOnMarkerClickListener(OnMarkerClickListener) method. The OnMarkerClickListener class defines theonMarkerClicked(Marker) method which is called if a marker is clicked.

2.4 Zoom Camera to view the Marker

Stay updated to know more about Maps in Android application !

 

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

Deniel Kerr

Owner and Founder. Opencart

Talk to Sales
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home