Reader small image

You're reading from  Android Wear Projects

Product typeBook
Published inJul 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781787123229
Edition1st Edition
Languages
Right arrow
Author (1)
Ashok Kumar S
Ashok Kumar S
author image
Ashok Kumar S

Ashok Kumar S has been working in the mobile development domain from about eight years. He is a Google certified engineer, speaker at global scale conferences and he also runs a youtube channel (AndroidABCD) for Android developers. He is an early Firebase adopter since before Google acquired Firebase. He is Computer Science and Engineering graduate who is completely passionate about innovation in technology. He contributes to open source heavily to improve his e-karma. Ashok has also written a book on Wear OS programming through a project approach.
Read more about Ashok Kumar S

Right arrow

Changing marker color and customizing


Using the MarkerOptions class, we can the and icon of the marker. The following code both the icon and color of the marker.

To change the color of the marker, please refer to the following code:

private void addMarker(Memory memory) {
    Marker marker = mMap.addMarker(new MarkerOptions()
          .draggable(true).icon(BitmapDescriptorFactory.defaultMarker
          (BitmapDescriptorFactory.HUE_CYAN)).alpha(0.7f)
            .position(new LatLng(memory.latitude, memory.longitude)));

    mMemories.put(marker.getId(), memory);
}

We can now see that the marker color is changed from red to cyan with transparency. If you wish to remove the transparency, you can remove the .alpha() value passed to marker options:

Changed marker color

To the to an icon the drawable directory, check following code:

private void addMarker(Memory memory) {
    Marker marker = mMap.addMarker(new MarkerOptions()
            .draggable(true).icon(BitmapDescriptorFactory.fromResource...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Android Wear Projects
Published in: Jul 2017Publisher: PacktISBN-13: 9781787123229

Author (1)

author image
Ashok Kumar S

Ashok Kumar S has been working in the mobile development domain from about eight years. He is a Google certified engineer, speaker at global scale conferences and he also runs a youtube channel (AndroidABCD) for Android developers. He is an early Firebase adopter since before Google acquired Firebase. He is Computer Science and Engineering graduate who is completely passionate about innovation in technology. He contributes to open source heavily to improve his e-karma. Ashok has also written a book on Wear OS programming through a project approach.
Read more about Ashok Kumar S