GoogleMap.addMarker()returns an instance ofMarker.
If necessary, you can cast the returned value toAdvancedMarker.
UseAdvancedMarkerOptionsto configure advanced markers.AdvancedMarkerOptionsis a subclass ofMarkerOptionsso it supports all the same settings asMarkerOptions.
AdvancedMarkerOptionsalso lets you:
Create an instance of thePinConfigclass, and then use thePinConfiginstance to configure theAdvancedMarkerOptionsinstance.
UsePinConfigto customize advanced marker properties, such as the
background color, border color, and glyph.
Create an instance of the AndroidViewclass
and use that instance to configure theAdvancedMarkerOptionsinstance.
The View instance lets you fully customize the marker.
Use PinConfig
ThePinConfigclass contains options to customize
advanced markers. UsePinConfigto:
// Use PinConfig.Builder to create an instance of PinConfig.valpinConfigBuilder:PinConfig.Builder=PinConfig.builder()pinConfigBuilder.setBackgroundColor(Color.MAGENTA)valpinConfig:PinConfig=pinConfigBuilder.build()
// Use the PinConfig instance to set the icon for AdvancedMarkerOptions.valadvancedMarkerOptions:AdvancedMarkerOptions=AdvancedMarkerOptions().icon(BitmapDescriptorFactory.fromPinConfig(pinConfig)).position(MARKER_POSITION)
// Pass the AdvancedMarkerOptions instance to addMarker().valmarker:Marker?=map.addMarker(advancedMarkerOptions)
Java
// Use PinConfig.Builder to create an instance of PinConfig.PinConfig.BuilderpinConfigBuilder=PinConfig.builder();pinConfigBuilder.setBackgroundColor(Color.MAGENTA);PinConfigpinConfig=pinConfigBuilder.build(); // Use the PinConfig instance to set the icon for AdvancedMarkerOptions.AdvancedMarkerOptionsadvancedMarkerOptions=newAdvancedMarkerOptions().icon(BitmapDescriptorFactory.fromPinConfig(pinConfig)).position(MARKER_POSITION); // Pass the AdvancedMarkerOptions instance to addMarker().Markermarker=map.addMarker(advancedMarkerOptions);
Change the background color
Use thePinConfig.background()method to change the background color of a
marker:
Kotlin
// Use PinConfig.Builder to create an instance of PinConfig.valpinConfigBuilder:PinConfig.Builder=PinConfig.builder()pinConfigBuilder.setBackgroundColor(Color.MAGENTA)valpinConfig:PinConfig=pinConfigBuilder.build()
Java
// Use PinConfig.Builder to create an instance of PinConfig.PinConfig.BuilderpinConfigBuilder=PinConfig.builder();pinConfigBuilder.setBackgroundColor(Color.MAGENTA);PinConfigpinConfig=pinConfigBuilder.build();
Change the border color
Use thePinConfig.borderColor()method to change the border color of a
marker:
Kotlin
// Set the border color.valpinConfigBuilder:PinConfig.Builder=PinConfig.builder()pinConfigBuilder.setBorderColor(Color.BLUE)valpinConfig:PinConfig=pinConfigBuilder.build()
Java
// Set the border color.PinConfig.BuilderpinConfigBuilder=PinConfig.builder();pinConfigBuilder.setBorderColor(Color.BLUE);PinConfigpinConfig=pinConfigBuilder.build();
Change the glyph
Create aGlyphinstance and then use that instance to configurePinConfig.
Use the glyph to set the glyph text and text color, the glyph color, or to
specify a custom image to use as the glyph.
The following example sets the glyph text:
Kotlin
// Set the glyph text.valpinConfigBuilder:PinConfig.Builder=PinConfig.builder()valglyphText=Glyph("A") // Alteratively, you can set the text color:// Glyph glyphText = new Glyph("A", Color.GREEN); pinConfigBuilder.setGlyph(glyphText)valpinConfig:PinConfig=pinConfigBuilder.build()
Java
// Set the glyph text.PinConfig.BuilderpinConfigBuilder=PinConfig.builder();PinConfig.GlyphglyphText=newPinConfig.Glyph("A"); // Alternatively, you can set the text color:// PinConfig.Glyph glyphText = new PinConfig.Glyph("A", Color.GREEN); pinConfigBuilder.setGlyph(glyphText);PinConfigpinConfig=pinConfigBuilder.build();
Set a custom image for the glyph. This technique is useful if you want to use a
custom logo or other visual indicator in the marker.
Kotlin
// Set the glyph image.valglyphImage:Int=R.drawable.example_imagevaldescriptor=PinConfig.BitmapDescriptorFactory.fromResource(glyphImage)pinConfigBuilder.setGlyph(Glyph(descriptor))valpinConfig:PinConfig=pinConfigBuilder.build()
Java
// Set the glyph image.intglyphImage=R.drawable.example_image;BitmapDescriptordescriptor=BitmapDescriptorFactory.fromResource(glyphImage);pinConfigBuilder.setGlyph(newPinConfig.Glyph(descriptor));PinConfigpinConfig=pinConfigBuilder.build();
Hide the glyph
You can hide the glyph so that the background color fills the entire marker:
Kotlin
// Create a transparent glyph.valpinConfigBuilder:PinConfig.Builder=PinConfig.builder()pinConfigBuilder.setBackgroundColor(Color.MAGENTA)pinConfigBuilder.setGlyph(PinConfig.Glyph(Color.TRANSPARENT))valpinConfig:PinConfig=pinConfigBuilder.build()
Java
// Create a transparent glyph.PinConfig.BuilderpinConfigBuilder=PinConfig.builder();pinConfigBuilder.setBackgroundColor(Color.MAGENTA);pinConfigBuilder.setGlyph(newPinConfig.Glyph(Color.TRANSPARENT));PinConfigpinConfig=pinConfigBuilder.build();
Use iconView
TheAdvancedMarkerOptions.iconView()method lets you use any AndroidViewas the marker. By using a view as the marker, you have complete control over the
marker.
In your app, you first create the view, then use theAdvancedMarkerOptions.iconView()method to add the view to the
advanced markers.
Kotlin
// Create a TextView to use as the marker.valtextView=TextView(this)textView.text="Hello!!"textView.setBackgroundColor(Color.BLACK)textView.setTextColor(Color.YELLOW) valmarker:Marker?=map.addMarker(AdvancedMarkerOptions().position(SYDNEY).iconView(textView))
Java
// Create a TextView to use as the marker.TextViewtextView=newTextView(this);textView.setText("Hello!!");textView.setBackgroundColor(Color.BLACK);textView.setTextColor(Color.YELLOW); Markermarker=map.addMarker(newAdvancedMarkerOptions().position(SYDNEY).iconView(textView));
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eAdvanced markers can be added to a map by creating an \u003ccode\u003eAdvancedMarkerOptions\u003c/code\u003e instance and using \u003ccode\u003eGoogleMap.addMarker()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eCustomize advanced marker properties, such as background color, border color, and glyph, by creating and configuring a \u003ccode\u003ePinConfig\u003c/code\u003e instance.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003eAdvancedMarkerOptions.iconView()\u003c/code\u003e method to utilize any Android View as the marker, offering complete customization control but potentially impacting performance.\u003c/p\u003e\n"],["\u003cp\u003eWhen using a \u003ccode\u003eView\u003c/code\u003e as a marker, manipulate the \u003ccode\u003eMarker\u003c/code\u003e itself for operations like rotation instead of directly modifying the \u003ccode\u003eView\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eFurther customization options include changing the background and border colors, setting the glyph, and hiding the glyph for a filled background.\u003c/p\u003e\n"]]],[],null,["# Create an advanced marker\n\nSelect platform: [Android](/maps/documentation/android-sdk/advanced-markers/add-marker \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/advanced-markers/add-marker \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/advanced-markers/add-marker \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nTo add advanced markers to a map, create a new instance of\n[`AdvancedMarkerOptions`](/android/reference/com/google/android/gms/maps/model/AdvancedMarkerOptions)\nand then use\n[`GoogleMap.addMarker()`](/android/reference/com/google/android/gms/maps/GoogleMap#addMarker(com.google.android.gms.maps.model.MarkerOptions))\nto add the marker: \n\n### Kotlin\n\n\n```kotlin\nprivate val SYDNEY = LatLng(-33.87365, 151.20689)\n\nval marker: Marker? = map.addMarker(\n AdvancedMarkerOptions()\n .position(SYDNEY)\n .iconView(textView)\n .zIndex(zIndex)\n)\n```\n\n\u003cbr /\u003e\n\n### Java\n\n\n```java\nprivate final LatLng SYDNEY = new LatLng(-33.87365, 151.20689);\n\nMarker marker = map.addMarker(\n new AdvancedMarkerOptions()\n .position(SYDNEY)\n .iconView(textView)\n .zIndex(zIndex));\n```\n\n\u003cbr /\u003e\n\n`GoogleMap.addMarker()` returns an instance of\n[`Marker`](/android/reference/com/google/android/gms/maps/model/Marker).\nIf necessary, you can cast the returned value to\n[`AdvancedMarker`](/android/reference/com/google/android/gms/maps/model/AdvancedMarker).\n\nUse `AdvancedMarkerOptions` to configure advanced markers.\n`AdvancedMarkerOptions` is a subclass of\n[`MarkerOptions`](/android/reference/com/google/android/gms/maps/model/MarkerOptions)\nso it supports all the same settings as `MarkerOptions`.\n\n`AdvancedMarkerOptions` also lets you:\n\n- Create an instance of the\n [`PinConfig`](/android/reference/com/google/android/gms/maps/model/PinConfig)\n class, and then use the `PinConfig`\n instance to configure the `AdvancedMarkerOptions` instance.\n\n Use `PinConfig` to customize advanced marker properties, such as the\n background color, border color, and glyph.\n- Create an instance of the Android\n [`View`](https://developer.android.com/reference/android/view/View) class\n and use that instance to configure the `AdvancedMarkerOptions` instance.\n\n The View instance lets you fully customize the marker.\n\nUse PinConfig\n-------------\n\nThe `PinConfig` class contains options to customize\nadvanced markers. Use `PinConfig` to:\n\n- Change the background color\n- Change the border color\n- Change the glyph color or add text\n- Hide the glyph\n\n**Figure 1**: The parts of an Advanced Marker.\n\nUse [`PinConfig.Builder`](/android/reference/com/google/android/gms/maps/model/PinConfig.Builder)\nto create an instance of `PinConfig`: \n\n### Kotlin\n\n\n```kotlin\n// Use PinConfig.Builder to create an instance of PinConfig.\nval pinConfigBuilder: PinConfig.Builder = PinConfig.builder()\npinConfigBuilder.setBackgroundColor(Color.MAGENTA)\nval pinConfig: PinConfig = pinConfigBuilder.build()\n\n// Use the PinConfig instance to set the icon for AdvancedMarkerOptions.\nval advancedMarkerOptions: AdvancedMarkerOptions = AdvancedMarkerOptions()\n .icon(BitmapDescriptorFactory.fromPinConfig(pinConfig))\n .position(MARKER_POSITION)\n\n// Pass the AdvancedMarkerOptions instance to addMarker().\nval marker: Marker? = map.addMarker(advancedMarkerOptions)\n```\n\n\u003cbr /\u003e\n\n### Java\n\n\n```java\n// Use PinConfig.Builder to create an instance of PinConfig.\nPinConfig.Builder pinConfigBuilder = PinConfig.builder();\npinConfigBuilder.setBackgroundColor(Color.MAGENTA);\nPinConfig pinConfig = pinConfigBuilder.build();\n\n// Use the PinConfig instance to set the icon for AdvancedMarkerOptions.\nAdvancedMarkerOptions advancedMarkerOptions =\n new AdvancedMarkerOptions()\n .icon(BitmapDescriptorFactory.fromPinConfig(pinConfig))\n .position(MARKER_POSITION);\n\n// Pass the AdvancedMarkerOptions instance to addMarker().\nMarker marker = map.addMarker(advancedMarkerOptions);\n```\n\n\u003cbr /\u003e\n\n### Change the background color\n\nUse the `PinConfig.background()` method to change the background color of a\nmarker: \n\n### Kotlin\n\n\n```kotlin\n// Use PinConfig.Builder to create an instance of PinConfig.\nval pinConfigBuilder: PinConfig.Builder = PinConfig.builder()\npinConfigBuilder.setBackgroundColor(Color.MAGENTA)\nval pinConfig: PinConfig = pinConfigBuilder.build()\n```\n\n\u003cbr /\u003e\n\n### Java\n\n\n```java\n// Use PinConfig.Builder to create an instance of PinConfig.\nPinConfig.Builder pinConfigBuilder = PinConfig.builder();\npinConfigBuilder.setBackgroundColor(Color.MAGENTA);\nPinConfig pinConfig = pinConfigBuilder.build();\n```\n\n\u003cbr /\u003e\n\n### Change the border color\n\nUse the `PinConfig.borderColor()` method to change the border color of a\nmarker: \n\n### Kotlin\n\n\n```kotlin\n// Set the border color.\nval pinConfigBuilder: PinConfig.Builder = PinConfig.builder()\npinConfigBuilder.setBorderColor(Color.BLUE)\nval pinConfig: PinConfig = pinConfigBuilder.build()\n```\n\n\u003cbr /\u003e\n\n### Java\n\n\n```java\n// Set the border color.\nPinConfig.Builder pinConfigBuilder = PinConfig.builder();\npinConfigBuilder.setBorderColor(Color.BLUE);\nPinConfig pinConfig = pinConfigBuilder.build();\n```\n\n\u003cbr /\u003e\n\n### Change the glyph\n\nCreate a [`Glyph`](/android/reference/com/google/android/gms/maps/model/PinConfig.Glyph)\ninstance and then use that instance to configure `PinConfig`.\nUse the glyph to set the glyph text and text color, the glyph color, or to\nspecify a custom image to use as the glyph.\n\nThe following example sets the glyph text: \n\n### Kotlin\n\n\n```kotlin\n// Set the glyph text.\nval pinConfigBuilder: PinConfig.Builder = PinConfig.builder()\nval glyphText = Glyph(\"A\")\n\n// Alteratively, you can set the text color:\n// Glyph glyphText = new Glyph(\"A\", Color.GREEN);\n\npinConfigBuilder.setGlyph(glyphText)\nval pinConfig: PinConfig = pinConfigBuilder.build()\n```\n\n\u003cbr /\u003e\n\n### Java\n\n\n```java\n// Set the glyph text.\nPinConfig.Builder pinConfigBuilder = PinConfig.builder();\nPinConfig.Glyph glyphText = new PinConfig.Glyph(\"A\");\n\n// Alternatively, you can set the text color:\n// PinConfig.Glyph glyphText = new PinConfig.Glyph(\"A\", Color.GREEN);\n\npinConfigBuilder.setGlyph(glyphText);\nPinConfig pinConfig = pinConfigBuilder.build();\n```\n\n\u003cbr /\u003e\n\nSet the glyph color: \n\n### Kotlin\n\n\n```kotlin\nval glyphColor = PinConfig.Glyph(Color.BLUE)\npinConfigBuilder.setGlyph(glyphColor)\nval pinConfig: PinConfig = pinConfigBuilder.build()\n```\n\n\u003cbr /\u003e\n\n### Java\n\n\n```java\nPinConfig.Glyph glyphColor = new PinConfig.Glyph(Color.BLUE);\npinConfigBuilder.setGlyph(glyphColor);\nPinConfig pinConfig = pinConfigBuilder.build();\n```\n\n\u003cbr /\u003e\n\nSet a custom image for the glyph. This technique is useful if you want to use a\ncustom logo or other visual indicator in the marker. \n\n### Kotlin\n\n\n```kotlin\n// Set the glyph image.\nval glyphImage: Int = R.drawable.example_image\nval descriptor = PinConfig.BitmapDescriptorFactory.fromResource(glyphImage)\npinConfigBuilder.setGlyph(Glyph(descriptor))\nval pinConfig: PinConfig = pinConfigBuilder.build()\n```\n\n\u003cbr /\u003e\n\n### Java\n\n\n```java\n// Set the glyph image.\nint glyphImage = R.drawable.example_image;\nBitmapDescriptor descriptor = BitmapDescriptorFactory.fromResource(glyphImage);\npinConfigBuilder.setGlyph(new PinConfig.Glyph(descriptor));\nPinConfig pinConfig = pinConfigBuilder.build();\n```\n\n\u003cbr /\u003e\n\n### Hide the glyph\n\nYou can hide the glyph so that the background color fills the entire marker: \n\n### Kotlin\n\n\n```kotlin\n// Create a transparent glyph.\nval pinConfigBuilder: PinConfig.Builder = PinConfig.builder()\npinConfigBuilder.setBackgroundColor(Color.MAGENTA)\npinConfigBuilder.setGlyph(PinConfig.Glyph(Color.TRANSPARENT))\nval pinConfig: PinConfig = pinConfigBuilder.build()\n```\n\n\u003cbr /\u003e\n\n### Java\n\n\n```java\n// Create a transparent glyph.\nPinConfig.Builder pinConfigBuilder = PinConfig.builder();\npinConfigBuilder.setBackgroundColor(Color.MAGENTA);\npinConfigBuilder.setGlyph(new PinConfig.Glyph(Color.TRANSPARENT));\nPinConfig pinConfig = pinConfigBuilder.build();\n```\n\n\u003cbr /\u003e\n\nUse iconView\n------------\n\nThe `AdvancedMarkerOptions.iconView()` method lets you use any Android\n[`View`](https://developer.android.com/reference/android/view/View)\nas the marker. By using a view as the marker, you have complete control over the\nmarker.\n| **Note:** When using a `View` as the marker, don't perform operation on the `View` to move it. Instead, modify the `Marker` itself. For example, to rotate the `View`, use the [`Marker.setRotation()`](/android/reference/com/google/android/gms/maps/model/Marker#setRotation(float)) method. Don't rotate `View`.\n\nIn your app, you first create the view, then use the\n`AdvancedMarkerOptions.iconView()` method to add the view to the\nadvanced markers. \n\n### Kotlin\n\n\n```kotlin\n// Create a TextView to use as the marker.\nval textView = TextView(this)\ntextView.text = \"Hello!!\"\ntextView.setBackgroundColor(Color.BLACK)\ntextView.setTextColor(Color.YELLOW)\n\nval marker: Marker? = map.addMarker(\n AdvancedMarkerOptions()\n .position(SYDNEY)\n .iconView(textView)\n)\n```\n\n\u003cbr /\u003e\n\n### Java\n\n\n```java\n// Create a TextView to use as the marker.\nTextView textView = new TextView(this);\ntextView.setText(\"Hello!!\");\ntextView.setBackgroundColor(Color.BLACK);\ntextView.setTextColor(Color.YELLOW);\n\nMarker marker = map.addMarker(\n new AdvancedMarkerOptions()\n .position(SYDNEY)\n .iconView(textView));\n```\n\n\u003cbr /\u003e\n\n| **Caution:** Performance of a map view with `iconView` markers might not match the performance of bitmap or default markers.\n\nNext steps:\n-----------\n\n- [Collision behavior](/maps/documentation/android-sdk/advanced-markers/collision-behavior)"]]