Usa la subclase GMSAdvancedMarker para crear funciones de marcadores básicos o específicos, como se muestra a continuación. Como subclase de GMSMarker, GMSAdvancedMarker proporciona marcadores con más expresión.
De manera similar a GMSMarker, puedes quitar un marcador avanzado del mapa configurando la propiedad del mapa de GMSAdvancedMarker en nil. Como alternativa, puedes quitar todas las superposiciones (incluidos los marcadores avanzados) del mapa llamando al método clear de GMSMapView.
Si deseas modificar un marcador después de agregarlo al mapa, asegúrate de conservar el objeto GMSAdvancedMarker. Para modificar el marcador en otro momento, realiza cambios a este objeto.
La propiedad mapCapabilities en GMSMapView agrega una verificación programática para las funciones específicas del mapa. ίες útil cuando se desea saber si ciertas capacidades del mapa están disponibles antes de llamar a APIs específicas. La función didChangeMapCapabilities de GMSMapViewDelegate también se invoca cuando cambian las capacidades.
Esta consulta determina si la vista del mapa admite marcadores avanzados.
// ..._advancedMarker=[GMSAdvancedMarkermarkerWithPosition:kSeattleCoordinates];_fallbackMarker=[GMSMarkermarkerWithPosition:kSeattleCoordinates];-(void)addMarker{if(_mapView.mapCapabilities&GMSMapCapabilityFlagsAdvancedMarkers){_advancedMarker.map=_mapView;}else{_fallbackMarker.map=_mapView;}}#pragma mark - GMSMapViewDelegate-(void)mapView:(GMSMapView*)mapViewdidChangeMapCapabilities:(GMSMapCapabilityFlags)mapCapabilities{BOOLadvancedMarkersAvailable=mapCapabilities&GMSMapCapabilityFlagsAdvancedMarkers;_advancedMarker.map=advancedMarkersAvailable?_mapView:nil;_fallbackMarker.map=advancedMarkersAvailable?nil:_mapView;}
[null,null,["Última actualización: 2025-08-31 (UTC)"],[[["\u003cp\u003eThe \u003ccode\u003eGMSAdvancedMarker\u003c/code\u003e subclass in the Maps SDK for iOS allows you to create markers with enhanced features and customization options, inheriting functionalities from \u003ccode\u003eGMSMarker\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can remove an advanced marker by setting its \u003ccode\u003emap\u003c/code\u003e property to \u003ccode\u003enil\u003c/code\u003e or use the \u003ccode\u003eclear\u003c/code\u003e method of \u003ccode\u003eGMSMapView\u003c/code\u003e to remove all overlays, including advanced markers.\u003c/p\u003e\n"],["\u003cp\u003eTo modify an existing marker, retain the \u003ccode\u003eGMSAdvancedMarker\u003c/code\u003e object and make changes to its properties.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003emapCapabilities\u003c/code\u003e property of \u003ccode\u003eGMSMapView\u003c/code\u003e enables checking for map features programmatically, such as support for advanced markers, before using related APIs, ensuring compatibility.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edidChangeMapCapabilities\u003c/code\u003e function of the \u003ccode\u003eGMSMapViewDelegate\u003c/code\u003e is triggered when map capabilities change, offering a way to dynamically adapt marker usage based on available features.\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\nUse the [`GMSAdvancedMarker`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSAdvancedMarker) subclass to create basic or\nspecific marker features, as shown below. As a subclass of\n[`GMSMarker`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMarker), `GMSAdvancedMarker` provides markers with more\nexpression. \n\n### Swift\n\n```swift\nlet camera = GMSCameraPosition( target: coordinate, zoom: 14)\nlet mapID = GMSMapID(identifier: \"YOUR_MAP_ID\")\nlet mapView = GMSMapView(frame: view.bounds, mapID: mapID, camera: camera)\n\nlet marker = GMSAdvancedMarker(position: coordinate)\nmarker.map = mapView\n```\n\n### Objective-C\n\n```objective-c\nGMSCameraPosition *camera = [GMSCameraPosition cameraWithTarget:kCoordinate zoom:16];\nGMSMapID *mapID = [GMSMapID mapIDWithIdentifier:\"YOUR_MAP_ID\"];\n\nself.mapView = [GMSMapView mapWithFrame:self.view.bounds mapID:mapID camera:camera];\n\nGMSAdvancedMarker *marker = [GMSAdvancedMarker markerWithPosition:kCoordinate];\nMarker.map = self.mapView;\n```\n| Note: For testing, you can skip the step of creating and configuring a [map ID](/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.\n\nRemove an advanced marker\n-------------------------\n\nSimilar to [`GMSMarker`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMarker), you can remove an advanced marker from the\nmap by setting the map property of the [`GMSAdvancedMarker`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSAdvancedMarker)\nto `nil`. Alternatively, you can remove all of the overlays (including advanced\nmarkers) on the map by calling the [`GMSMapView`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView) `clear` method.\n\n\n### Swift\n\n```swift\nlet camera = GMSCameraPosition.camera(\n withLatitude: -33.8683,\n longitude: 151.2086,\n zoom: 6\n)\nlet mapView = GMSMapView.map(withFrame: .zero, camera: camera)\n// ...\nmapView.clear()\n \n```\n\n### Objective-C\n\n```objective-c\nGMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683\n longitude:151.2086\n zoom:6];\nmapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];\n// ...\n[mapView clear];\n \n```\n\n\u003cbr /\u003e\n\nIf you want to make modifications to a marker after you've added it to the map,\nensure that you keep hold of the [`GMSAdvancedMarker`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSAdvancedMarker)\nobject. You can modify the marker later by making changes to this object. \n\n### Swift\n\n```swift\nlet position = CLLocationCoordinate2D(latitude: 10, longitude: 10)\nlet marker = GMSAdvancedMarker(position: position)\nmarker.map = mapView\n// ...\nmarker.map = nil\n```\n\n### Objective-C\n\n```objective-c\nCLLocationCoordinate2D position = CLLocationCoordinate2DMake(10, 10);\nGMSAdvancedMarker *marker = [GMSAdvancedMarker markerWithPosition:position];\nmarker.map = mapView;\n// ...\nmarker.map = nil;\n```\n\nMap capabilities\n----------------\n\nThe `mapCapabilities` property on [`GMSMapView`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView) adds programmatic\nchecking for map-specific features. This is useful when wanting to know if\ncertain map capabilities are available before calling specific APIs. The\n`didChangeMapCapabilities` function of\n[`GMSMapViewDelegate`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate) is also\n[invoked](/maps/documentation/ios-sdk/marker-gestures) as capabilities change.\nThis query determines if the map view supports advanced markers. \n\n### Swift\n\n```swift\n// ...\n\nlet advancedMarker: GMSAdvancedMarker = {\nGMSAdvancedMarker(position: CLLocationCoordinate2D(latitude: 47.6089945, longitude: -122.3410462))\n}()\n\nlet marker: GMSMarker = {\nGMSMarker(position: CLLocationCoordinate2D(latitude: 47.6089945, longitude: -122.3410462))\n}()\n\nfunc addMarker() {\n if mapView.mapCapabilities.contains(.advancedMarkers) {\n advancedMarker.map = mapView\n } else {\n marker.map = mapView\n }\n}\n\nextension MapCapabilities: GMSMapViewDelegate {\n func mapView(_ mapView: GMSMapView, didChangeMapCapabilities mapCapabilities: GMSMapCapabilityFlags) {\n\n let advancedMarkerAvailable = mapCapabilities.contains(.advancedMarkers)\n\n advancedMarker.map = advancedMarkerAvailable ? mapView : nil\n marker.map = advancedMarkerAvailable ? nil : mapView\n }\n}\n```\n\n### Objective-C\n\n```objective-c\n// ...\n\n_advancedMarker = [GMSAdvancedMarker markerWithPosition: kSeattleCoordinates];\n_fallbackMarker = [GMSMarker markerWithPosition: kSeattleCoordinates];\n\n- (void)addMarker {\n\n if (_mapView.mapCapabilities & GMSMapCapabilityFlagsAdvancedMarkers) {\n _advancedMarker.map = _mapView;\n } else {\n _fallbackMarker.map = _mapView;\n }\n}\n\n#pragma mark - GMSMapViewDelegate\n\n- (void)mapView:(GMSMapView *)mapView\n didChangeMapCapabilities:(GMSMapCapabilityFlags)mapCapabilities {\n BOOL advancedMarkersAvailable = mapCapabilities & GMSMapCapabilityFlagsAdvancedMarkers;\n _advancedMarker.map = advancedMarkersAvailable ? _mapView : nil;\n _fallbackMarker.map = advancedMarkersAvailable ? nil : _mapView;\n}\n```"]]