Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Android Google Maps

You're reading from   Learning Android Google Maps Integrate Google Maps with your Android application to offer feature-rich and interactive maps

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher Packt
ISBN-13 9781849698863
Length 356 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (13) Chapters Close

Preface 1. Setting Up the Development Environment 2. Configuring an API Key and Creating Our First Map Application FREE CHAPTER 3. Working with Different Map Types 4. Adding Information to Maps 5. Interacting with a Map 6. Working with Custom Views 7. Working with Location Data 8. Know about the Street View 9. Google Maps Intents 10. Creating a Custom Map Application A. Answers to Self-test Questions Index

Adding information with markers


Markers can be used to indicate a particular location on a map. A marker can be customized by changing its color or using a custom image instead of a marker icon. This image is an example of a marker:

How to add a marker?

We need to use a Marker object to work with markers. A new marker can be added with the following method:

GoogleMap.addMarker()

This code takes the parameter as the MarkerOptions object. The latitude and longitude are set for the map using a LatLng object. The latitude and longitude can also be set as follows

MarkerOptions().position()

This method takes the LatLng object as a parameter. Now, let's create a sample app that displays a marker in Newark city. Let's see how we can code it. The code for our main layout is the same as the one we used in our previous chapters.

<?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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image