Select platform: [Android](https://developers.google.com/maps/documentation/android-sdk/advanced-markers/add-marker.md.txt "View this page for the Android platform docs.") [iOS](https://developers.google.com/maps/documentation/ios-sdk/advanced-markers/add-marker.md.txt "View this page for the iOS platform docs.") [JavaScript](https://developers.google.com/maps/documentation/javascript/advanced-markers/add-marker.md.txt "View this page for the JavaScript platform docs.")

<br />

Use the [`GMSAdvancedMarker`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSAdvancedMarker.md.txt) subclass to create basic or
specific marker features, as shown below. As a subclass of
[`GMSMarker`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSMarker.md.txt), `GMSAdvancedMarker` provides markers with more
expression.

### Swift

```swift
let camera = GMSCameraPosition( target: coordinate, zoom: 14)
let mapID = GMSMapID(identifier: "YOUR_MAP_ID")
let options = GMSMapViewOptions()
options.camera = camera
options.mapID = mapID
options.frame = view.bounds
let mapView = GMSMapView(options: options)

let marker = GMSAdvancedMarker(position: coordinate)
marker.map = mapView
```

### Objective-C

```objective-c
GMSCameraPosition *camera = [GMSCameraPosition cameraWithTarget:kCoordinate zoom:16];
GMSMapID *mapID = [GMSMapID mapIDWithIdentifier:@"YOUR_MAP_ID"];

GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init];
options.camera = camera;
options.mapID = mapID;
options.frame = self.view.bounds;
self.mapView = [[GMSMapView alloc] initWithOptions:options];

GMSAdvancedMarker *marker = [GMSAdvancedMarker markerWithPosition:kCoordinate];
marker.map = self.mapView;
```
Note: For testing, you can skip the step of creating and configuring a [map ID](https://developers.google.com/maps/documentation/get-map-id), by using mapId: `DEMO_MAP_ID` in your app code. `DEMO_MAP_ID` is intended for testing purposes only. Don't use `DEMO_MAP_ID` in a production environment.

## Remove an advanced marker

Similar to [`GMSMarker`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSMarker.md.txt), you can remove an advanced marker from the
map by setting the map property of the [`GMSAdvancedMarker`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSAdvancedMarker.md.txt)
to `nil`. Alternatively, you can remove all of the overlays (including advanced
markers) on the map by calling the [`GMSMapView`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView.md.txt) `clear` method.


### Swift

```swift
let camera = GMSCameraPosition.camera(
  withLatitude: -33.8683,
  longitude: 151.2086,
  zoom: 6
)
let options = GMSMapViewOptions()
options.camera = camera
let mapView = GMSMapView(options: options)
// ...
mapView.clear()
      
```

### Objective-C

```objective-c
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
                                                        longitude:151.2086
                                                             zoom:6];
GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init];
options.camera = camera;
mapView = [[GMSMapView alloc] initWithOptions:options];
// ...
[mapView clear];
      
```

<br />

If you want to make modifications to a marker after you've added it to the map,
ensure that you keep hold of the [`GMSAdvancedMarker`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSAdvancedMarker.md.txt)
object. You can modify the marker later by making changes to this object.

### Swift

```swift
let position = CLLocationCoordinate2D(latitude: 10, longitude: 10)
let marker = GMSAdvancedMarker(position: position)
marker.map = mapView
// ...
marker.map = nil
```

### Objective-C

```objective-c
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(10, 10);
GMSAdvancedMarker *marker = [GMSAdvancedMarker markerWithPosition:position];
marker.map = mapView;
// ...
marker.map = nil;
```

## Map capabilities

The `mapCapabilities` property on [`GMSMapView`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView.md.txt) adds programmatic
checking for map-specific features. This is useful when wanting to know if
certain map capabilities are available before calling specific APIs. The
`didChangeMapCapabilities` function of
[`GMSMapViewDelegate`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate.md.txt) is also
[invoked](https://developers.google.com/maps/documentation/ios-sdk/marker-gestures.md.txt) as capabilities change.
This query determines if the map view supports advanced markers.

### Swift

```swift
// ...

let advancedMarker: GMSAdvancedMarker = {
GMSAdvancedMarker(position: CLLocationCoordinate2D(latitude: 47.6089945, longitude: -122.3410462))
}()

let marker: GMSMarker = {
GMSMarker(position: CLLocationCoordinate2D(latitude: 47.6089945, longitude: -122.3410462))
}()

func addMarker() {
  if mapView.mapCapabilities.contains(.advancedMarkers) {
      advancedMarker.map = mapView
    } else {
      marker.map = mapView
    }
}

extension MapCapabilities: GMSMapViewDelegate {
  func mapView(_ mapView: GMSMapView, didChangeMapCapabilities mapCapabilities: GMSMapCapabilityFlags) {

     let advancedMarkerAvailable = mapCapabilities.contains(.advancedMarkers)

     advancedMarker.map = advancedMarkerAvailable ? mapView : nil
     marker.map = advancedMarkerAvailable ? nil : mapView
  }
}
```

### Objective-C

```objective-c
// ...

_advancedMarker = [GMSAdvancedMarker markerWithPosition:  kSeattleCoordinates];
_fallbackMarker = [GMSMarker markerWithPosition: kSeattleCoordinates];

-   (void)addMarker {

  if (_mapView.mapCapabilities & GMSMapCapabilityFlagsAdvancedMarkers) {
    _advancedMarker.map = _mapView;
    } else {
    _fallbackMarker.map = _mapView;
  }
}

#pragma mark - GMSMapViewDelegate

-   (void)mapView:(GMSMapView *)mapView
    didChangeMapCapabilities:(GMSMapCapabilityFlags)mapCapabilities {
  BOOL advancedMarkersAvailable = mapCapabilities & GMSMapCapabilityFlagsAdvancedMarkers;
  _advancedMarker.map = advancedMarkersAvailable ? _mapView : nil;
  _fallbackMarker.map = advancedMarkersAvailable ? nil : _mapView;
}
```