Ortssymbole kennzeichnen die verschiedenen Arten von Orten, z. B. Cafés, Bibliotheken und Museen. Sie können URLs für Symbole im PNG-Format sowie die entsprechende Hintergrundfarbe des Symbols über Current Place- und Place Details-Anfragen anfordern.
Wenn Sie ein Symbolbild und eine Hintergrundfarbe für einen Ort anfordern möchten, fügen Sie Ihrer Anfrage die folgenden Felder hinzu:
GMSPlaceFieldIconImageURL
GMSPlaceFieldIconBackgroundColor
In den folgenden Beispielen wird gezeigt, wie das Symbolbild und die Hintergrundfarbe aus einer Anfrage vom Typ „Current Place“ oder „Place Details“ verwendet werden:
Places Swift SDK for iOS
// Initialize Places Swift clientletplacesClient=PlacesClient.shared// A hotel in Saigon with an attribution.letplaceID="ChIJV4k8_9UodTERU5KXbkYpSYs"// Specify the place data types to return.letfetchPlaceRequest=FetchPlaceRequest(placeID:placeID,placeProperties:[.displayName,.iconMaskURL,.iconBackgroundColor])Task{switchawaitplacesClient.fetchPlace(with:fetchPlaceRequest){case.success(letplace):// Print displayName using String(describing:)print("The selected place is: \(String(describing:place.displayName))")// We primarily need the iconMaskURL to proceed with image loading.// iconBackgroundColor can be handled even if nil.guardleticonMaskURL=place.iconMaskURLelse{print("Icon mask URL not available for this place. Cannot display icon.")return// Exit if iconMaskURL is missing}print("The icon mask URL is: \(iconMaskURL)")// Print iconBackgroundColor using String(describing:)print("The icon background color is: \(String(describing:place.iconBackgroundColor))")// Asynchronously load the icon imageDispatchQueue.global().async{// The iconMaskURL from the new Places SDK is already a URLguardletimageData=try?Data(contentsOf:iconMaskURL)else{print("Could not download image data from URL: \(iconMaskURL)")return}DispatchQueue.main.async{guardleticonImage=UIImage(data:imageData)else{print("Could not create UIImage from downloaded data.")return}// --- Example of how you might use the icon and background color ---// Ensure you have an imageView outlet connected in your UI// For example:// @IBOutlet weak var myImageViewContainer: UIView!// @IBOutlet weak var myIconImageView: UIImageView!// For this example, we'll create them programmatically:leticonBackgroundView=UIView(frame:CGRect(x:0,y:0,width:50,height:50))// Adjust frame as needed// Directly assign the optional UIColor. If nil, background will be clear.iconBackgroundView.backgroundColor=place.iconBackgroundColorletimageView=UIImageView()// Initialize an empty UIImageViewimageView.frame=iconBackgroundView.bounds// Make icon view same size as backgroundimageView.contentMode=.scaleAspectFit// Adjust content mode as needed// Tint the icon image (mask) to white// The icon from iconMaskURL is intended to be used as a mask.lettemplateImage=iconImage.withRenderingMode(.alwaysTemplate)imageView.image=templateImageimageView.tintColor=UIColor.white// Add the image view on top of the background viewiconBackgroundView.addSubview(imageView)}}}}
Swift
// Icon image URLleturl=URL(string:place.iconImageUrl)DispatchQueue.global().async{guardleturl=url,letimageData=try?Data(contentsOf:url)else{print("Could not get image")return}DispatchQueue.main.async{leticonImage=UIImage(data:iconImageData)// Icon image background colorleticonBackgroundView=UIView(frame:.zero)iconBackgroundView.backgroundColor=place.iconBackgroundColor// Change icon image color to whitelettemplateImage=iconImage.imageWithRenderingMode(UIImageRenderingModeAlwaysTemplate)imageView.image=templateImageimageView.tintColor=UIColor.white}}
Objective-C
GMSPlace*place;dispatch_async(dispatch_get_global_queue(0,0),^{// Icon image URLNSData*iconImageData=[[NSDataalloc]initWithContentsOfURL:[NSURLURLWithString:place.iconImageUrl]];if(!iconImageData)return;dispatch_async(dispatch_get_main_queue(),^{UIImage*iconImage=[UIImageimageWithData:iconImageData];// Icon image background colorUIView*iconBackgroundView=[[UIViewalloc]initWithFrame:CGRectZero];[iconBackgroundViewsetBackgroundColor:place.iconBackgroundColor];// Change icon image color to whiteiconImage=[iconImageimageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];[imageViewsetTintColor:[UIColorwhiteColor]];});});
Felder
Jedes Ortssymbol enthält die folgenden Felder:
iconImageUrl gibt die Basis-URL für ein nicht farbiges PNG-Symbol zurück.
iconBackgroundColor gibt den standardmäßigen UIExtendedSRGBColorSpace-Farbcode für die Kategorie des Orts zurück.
Anfragen für Ortssymbole und Hintergrundfarben
In den folgenden Tabellen finden Sie alle verfügbaren Ortssymbole nach Kategorie. Standardmäßig werden sie mit einer schwarzen Glyphe angezeigt. Die Hintergrundfarbe des Symbols richtet sich nach der Kategorie des Orts.
Ortskategorie: Essen und Trinken (Symbolhintergrundfarbe #FF9E67)
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-27 (UTC)."],[[["\u003cp\u003ePlace icons, representing various place types like restaurants and libraries, can be accessed through Place Details and Current Place requests.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve icon URLs in PNG format and their background colors using \u003ccode\u003eGMSPlaceFieldIconImageURL\u003c/code\u003e and \u003ccode\u003eGMSPlaceFieldIconBackgroundColor\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eiconImageUrl\u003c/code\u003e provides the base URL for the icon and \u003ccode\u003eiconBackgroundColor\u003c/code\u003e returns the color code associated with the place's category.\u003c/p\u003e\n"],["\u003cp\u003eIcon URLs are subject to change, therefore ensure using \u003ccode\u003eiconImageUrl\u003c/code\u003e for icon retrieval.\u003c/p\u003e\n"],["\u003cp\u003ePlace icons are categorized and displayed with a black glyph by default, with background colors varying by category (e.g., Food and drink with #FF9E67).\u003c/p\u003e\n"]]],[],null,["# Place Icons\n\nSelect platform: [Android](/maps/documentation/places/android-sdk/icons \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/icons \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/place-icons \"View this page for the JavaScript platform docs.\") [Web Service](/maps/documentation/places/web-service/icons \"View this page for the Web Service platform docs.\")\n\nPlace icons indicate the various types of places (for example coffee shops,\nlibraries, and museums). You can request URLs for icons in PNG format, as well\nas the corresponding icon background color, with\n[Current Place](/maps/documentation/places/ios-sdk/current-place),\nand [Place Details](/maps/documentation/places/ios-sdk/place-details)\nrequests.\n\nTo request an icon image and background color for a place, include the\nfollowing fields in your request:\n\n- `GMSPlaceFieldIconImageURL`\n- `GMSPlaceFieldIconBackgroundColor`\n\nThe following examples demonstrate using the icon image and background color\nfrom a Current Place or Place Details request: \n\n### Places Swift SDK for iOS\n\n```swift\n// Initialize Places Swift client\nlet placesClient = PlacesClient.shared\n \n// A hotel in Saigon with an attribution.\nlet placeID = \"ChIJV4k8_9UodTERU5KXbkYpSYs\"\n\n// Specify the place data types to return.\nlet fetchPlaceRequest = FetchPlaceRequest(\n placeID: placeID,\n placeProperties: [.displayName, .iconMaskURL, .iconBackgroundColor]\n)\n \nTask {\n switch await placesClient.fetchPlace(with: fetchPlaceRequest) {\n case .success(let place):\n // Print displayName using String(describing:)\n print(\"The selected place is: \\(String(describing: place.displayName))\")\n\n // We primarily need the iconMaskURL to proceed with image loading.\n // iconBackgroundColor can be handled even if nil.\n guard let iconMaskURL = place.iconMaskURL else {\n print(\"Icon mask URL not available for this place. Cannot display icon.\")\n return // Exit if iconMaskURL is missing\n }\n\n print(\"The icon mask URL is: \\(iconMaskURL)\")\n // Print iconBackgroundColor using String(describing:)\n print(\"The icon background color is: \\(String(describing: place.iconBackgroundColor))\")\n\n\n // Asynchronously load the icon image\n DispatchQueue.global().async {\n // The iconMaskURL from the new Places SDK is already a URL\n guard let imageData = try? Data(contentsOf: iconMaskURL) else {\n print(\"Could not download image data from URL: \\(iconMaskURL)\")\n return\n }\n\n DispatchQueue.main.async {\n guard let iconImage = UIImage(data: imageData) else {\n print(\"Could not create UIImage from downloaded data.\")\n return\n }\n\n // --- Example of how you might use the icon and background color ---\n // Ensure you have an imageView outlet connected in your UI\n // For example:\n // @IBOutlet weak var myImageViewContainer: UIView!\n // @IBOutlet weak var myIconImageView: UIImageView!\n // For this example, we'll create them programmatically:\n\n let iconBackgroundView = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) // Adjust frame as needed\n // Directly assign the optional UIColor. If nil, background will be clear.\n iconBackgroundView.backgroundColor = place.iconBackgroundColor\n\n let imageView = UIImageView() // Initialize an empty UIImageView\n imageView.frame = iconBackgroundView.bounds // Make icon view same size as background\n imageView.contentMode = .scaleAspectFit // Adjust content mode as needed\n\n // Tint the icon image (mask) to white\n // The icon from iconMaskURL is intended to be used as a mask.\n let templateImage = iconImage.withRenderingMode(.alwaysTemplate)\n imageView.image = templateImage\n imageView.tintColor = UIColor.white\n\n // Add the image view on top of the background view\n iconBackgroundView.addSubview(imageView)\n }\n }\n }\n}\n```\n\n### Swift\n\n```swift\n// Icon image URL\nlet url = URL(string: place.iconImageUrl)\nDispatchQueue.global().async {\n guard let url = url,\n let imageData = try? Data(contentsOf: url) else {\n print(\"Could not get image\")\n return\n }\n DispatchQueue.main.async {\n let iconImage = UIImage(data: iconImageData)\n\n // Icon image background color\n let iconBackgroundView = UIView(frame: .zero)\n iconBackgroundView.backgroundColor = place.iconBackgroundColor\n\n // Change icon image color to white\n let templateImage = iconImage.imageWithRenderingMode(UIImageRenderingModeAlwaysTemplate)\n imageView.image = templateImage\n imageView.tintColor = UIColor.white\n }\n}\n```\n\n### Objective-C\n\n```objective-c\nGMSPlace *place;\n\ndispatch_async(dispatch_get_global_queue(0, 0), ^{\n // Icon image URL\n NSData * iconImageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: place.iconImageUrl]];\n if (!iconImageData)\n return;\n dispatch_async(dispatch_get_main_queue(), ^{\n UIImage *iconImage = [UIImage imageWithData:iconImageData];\n\n // Icon image background color\n UIView *iconBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];\n [iconBackgroundView setBackgroundColor:place.iconBackgroundColor];\n\n // Change icon image color to white\n iconImage = [iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];\n [imageView setTintColor:[UIColor whiteColor]];\n });\n});\n```\n| Icon URLs may change, so be sure to always use `iconImageUrl` to look up the URL for an icon.\n\nFields\n------\n\nEach Place icon contains these fields:\n\n- `iconImageUrl` returns the base URL for a non-colored PNG icon.\n- `iconBackgroundColor` returns the default `UIExtendedSRGBColorSpace` color code for the place's category.\n\nPlace icon and background color requests\n----------------------------------------\n\nThe following tables show all of the available place icons by category. By\ndefault these display with a black glyph. The icon background color\nis dictated by the place's category.\n\n| **Place category: Food and drink** (icon background color #FF9E67) ||||\n|--------------------------------------------------------------------|-----------------------------------------|----------------------|------------------|\n| Bar, Night club | Cafe | Restaurant, Bakery |\n| Books, Clothing, Electronics, Jewelry, Shoes, Shopping center/Mall | Convenience store | Grocery, Supermarket | Pharmacy |\n| ATM | Bank | Gas | Lodging |\n| Post office |\n| Aquarium, Tourist | Golf | Historic | Movie |\n| Museum | Theater |\n| Airport | Bus, rideshare, taxi | Train/Rail |\n| Cemetery | Civic building | Library | Monument |\n| Parking | School (primary, secondary, university) | Worship (Christian) |\n| Worship (Hindu) | Worship (Islam) | Worship (Jain) | Worship (Jewish) |\n| Worship (Sikh) | Generic business |\n| Boating | Camping | Park | Stadium |\n| Zoo |\n| Hospital | Police |"]]