[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eInfo windows display information when a marker is tapped, showing a title and optional snippet text.\u003c/p\u003e\n"],["\u003cp\u003eCustomize info windows by creating a subclass of \u003ccode\u003eUIView\u003c/code\u003e and returning it in the \u003ccode\u003emapView:markerInfoWindow:\u003c/code\u003e delegate method.\u003c/p\u003e\n"],["\u003cp\u003eControl info window visibility programmatically using the \u003ccode\u003eselectedMarker\u003c/code\u003e property of \u003ccode\u003eGMSMapView\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAdjust the info window's position relative to the marker with the \u003ccode\u003einfoWindowAnchor\u003c/code\u003e property.\u003c/p\u003e\n"],["\u003cp\u003eListen to info window events like opening, closing, and long presses by implementing the \u003ccode\u003eGMSMapViewDelegate\u003c/code\u003e protocol.\u003c/p\u003e\n"]]],["Info windows display information when a user taps a marker, with the `title` and `snippet` properties defining its content. Only one info window can be displayed at once. Programmatically show/hide info windows by setting the `selectedMarker` property to a marker or `nil`. Enable automatic info window updates with `tracksInfoWindowChanges`. Modify info window position using `infoWindowAnchor`. Implement `GMSMapViewDelegate` to handle info window events. Customize content by creating a `UIView` subclass and implement the `mapView:markerInfoWindow:` event listener.\n"],null,["Select platform: [Android](/maps/documentation/android-sdk/infowindows \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/infowindows \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/infowindows \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nAn info window allows you to display information to the user when they tap on a\nmarker.\n\nAn info window is drawn oriented against the device's screen, centered above\nits associated marker. The default info window contains the title in bold,\nwith the snippet text below the title.\n\nThe contents of the info window are defined by the `title` and\n`snippet` properties of the marker. Clicking the marker does not display an\ninfo window if both the `title` and `snippet` properties are blank or `nil`.\n\nOnly one info window is displayed at a time. If a user taps on\nanother marker, the current window is hidden and the new info window opens.\nIf the user clicks on a marker that is currently showing an info window, that\ninfo window closes and reopens.\n\nCreate a custom info window to add additional text or images. A custom\ninfo window gives you complete control of the appearance of the popup.\n\nAdd an info window\n\nThe following snippet creates a simple marker, with only a title for the text\nof the info window.\n\n\nSwift \n\n```swift\nlet position = CLLocationCoordinate2D(latitude: 51.5, longitude: -0.127)\nlet london = GMSMarker(position: position)\nlondon.title = \"London\"\nlondon.map = mapView\n \n```\n\nObjective-C \n\n```objective-c\nCLLocationCoordinate2D position = CLLocationCoordinate2DMake(51.5, -0.127);\nGMSMarker *london = [GMSMarker markerWithPosition:position];\nlondon.title = @\"London\";\nlondon.map = mapView;\n \n```\n\n\u003cbr /\u003e\n\nWith the `snippet` property, you can add additional text that will appear\nbelow the title in a smaller font. Strings that are longer than the width of\nthe info window are automatically wrapped over several lines. Very long\nmessages may be truncated.\n\n\nSwift \n\n```swift\nlondon.title = \"London\"\nlondon.snippet = \"Population: 8,174,100\"\nlondon.map = mapView\n \n```\n\nObjective-C \n\n```objective-c\nlondon.title = @\"London\";\nlondon.snippet = @\"Population: 8,174,100\";\nlondon.map = mapView;\n \n```\n\n\u003cbr /\u003e\n\nShow/hide an info window\n\nInfo windows are designed to respond to user touch events on the marker.\nYou can show or hide an info window programmatically by setting the `selectedMarker`\nproperty of [`GMSMapView`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView):\n\n- Set `selectedMarker` to the name of the marker to show it.\n- Set `selectedMarker` to `nil` to hide it.\n\n\nSwift \n\n```swift\nlondon.title = \"London\"\nlondon.snippet = \"Population: 8,174,100\"\nlondon.map = mapView\n// Show marker\nmapView.selectedMarker = london\n// Hide marker\nmapView.selectedMarker = nil\n \n```\n\nObjective-C \n\n```objective-c\nlondon.title = @\"London\";\nlondon.snippet = @\"Population: 8,174,100\";\nlondon.map = mapView;\n// Show marker\nmapView.selectedMarker = london;\n// Hide marker\nmapView.selectedMarker = nil;\n \n```\n\n\u003cbr /\u003e\n\nSetting an info window to refresh automatically\n\nSet [`tracksInfoWindowChanges`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMarker#tracksinfowindowchanges) on the\nmarker to `YES` or `true` if you want new properties or the content of the info\nwindow to be immediately displayed when changed, rather than having to wait for\nthe info window to hide and then show again. The default is `NO` or `false`.\n\n\nSwift \n\n```swift\nlondon.tracksInfoWindowChanges = true\n \n```\n\nObjective-C \n\n```objective-c\nlondon.tracksInfoWindowChanges = YES;\n \n```\n\n\u003cbr /\u003e\n\nTo decide when to set the\n[`tracksInfoWindowChanges`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMarker#tracksinfowindowchanges) property, you\nshould weigh up performance considerations against the advantages of having the\ninfo window redrawn automatically. For example:\n\n- If you have a series of changes to make, you can change the property to `YES` then back to `NO`.\n- When an animation is running or the contents are being loaded asynchronously, you should keep the property set to `YES` until the actions are complete.\n\nRefer also to the [notes for consideration](#iconview-considerations) when\nusing the `iconView` property of the marker.\n\nChanging the position of an info window\n\nAn info window is drawn oriented against the device's screen, centered\nabove its associated marker. You can alter the position of the info window\nrelative to the marker by setting the `infoWindowAnchor` property. This\nproperty accepts a `CGPoint`, defined as an (x,y) offset where both x and y\nrange between 0.0 and 1.0. The default offset is (0.5, 0.0), that is, the center\ntop. Setting the `infoWindowAnchor` offset is useful for aligning the info\nwindow against a custom icon.\n\n\nSwift \n\n```swift\nlondon.infoWindowAnchor = CGPoint(x: 0.5, y: 0.5)\nlondon.icon = UIImage(named: \"house\")\nlondon.map = mapView\n \n```\n\nObjective-C \n\n```objective-c\nlondon.infoWindowAnchor = CGPointMake(0.5, 0.5);\nlondon.icon = [UIImage imageNamed:@\"house\"];\nlondon.map = mapView;\n \n```\n\n\u003cbr /\u003e\n\nHandling events on info windows\n\nYou can listen to the following info window events:\n\n- [`mapView:markerInfoWindow:`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate#-mapview:markerinfowindow:)\n --- Called when a marker is about to become selected.\n Can optionally return a custom info window, as a `UIView`, to use for\n the marker. See [Custom info windows](#custom-info-windows) below for more information.\n\n- [`mapView:markerInfoContents:`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate#-mapview:markerinfocontents:)\n --- Called when `mapView:markerInfoWindow` returns nil.\n\n- [`mapView:didCloseInfoWindowOfMarker:`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate#-mapview:didcloseinfowindowofmarker:)\n --- Called when the marker's info window is closed.\n\n- [`mapView:didLongPressInfoWindowOfMarker:`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate#-mapview:didlongpressinfowindowofmarker:)\n --- Called after a marker's info window has been long pressed.\n\nTo listen to events, you must implement the\n[`GMSMapViewDelegate`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate) protocol. See the\n[guide to events](/maps/documentation/ios-sdk/events) and the list of methods on the\n[`GMSMapViewDelegate`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate).\n\n[GitHub](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples)\nincludes samples that demonstrates how to handle info window events:\n\n- [Objective-C](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/blob/a1e79007cbc5a99579dbe2adeb23ab155030da46/GoogleMaps/GoogleMapsDemos/Samples/MarkerInfoWindowViewController.m)\n- [Swift](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/blob/main/GoogleMaps-Swift/GoogleMapsSwiftDemos/Swift/Samples/MarkerInfoWindowViewController.swift)\n\nCustom info windows \n\nCustomize the contents of info windows by creating a subclass of\n[`UIView`](https://developer.apple.com/documentation/uikit/uiview)\nthat defines the layout of the custom info window. In that subclass,\ndefine the view however you'd like. For example, you can use custom\n[`UILabel`](https://developer.apple.com/documentation/uikit/uilabel)\ninstances to display title and snippet text and other views, such as\n[`UIImageView`](https://developer.apple.com/documentation/uikit/uiimageview)\ninstances, to add images displayed in the info window.\n\nEnsure that your `ViewController` implements the\n[`GMSIndoorDisplayDelegate`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSIndoorDisplayDelegate)\nprotocol and defines a listener for the\n[mapView:markerInfoWindow:](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate#-mapview:markerinfowindow:)\nevent. This event listener is called when a marker is about to become\nselected, and lets you return an instance of your custom `UIView` class to\ndefine the custom info window used by the marker.\n| **Note:** The info window that is drawn is not a live view. The view is rendered as an image at the time it is returned. Any subsequent changes to the view will not be reflected by the info window on the map. Set [`tracksInfoWindowChanges`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMarker#tracksinfowindowchanges) on the marker to `YES` or `true` if you want new properties or the content of the info window to be immediately displayed when changed as shown above in [Setting an info window to refresh automatically](#set-an-info-window-to-refresh-automatically).\n\nThe images below show a default info window, an info window with customized\ncontents, and an info window with customized frame and background.\n\nThe code samples on\n[GitHub](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/tree/main/GoogleMaps)\nprovided with the Maps SDK for iOS\ninclude samples of custom info windows. For example, see the definition of\n[MarkerInfoWindowViewController.m](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/blob/main/GoogleMaps/GoogleMapsDemos/Samples/MarkerInfoWindowViewController.m)\n(Objective-C) or\n[MarkerInfoWindowViewController.swift](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/blob/main/GoogleMaps-Swift/GoogleMapsSwiftDemos/Swift/Samples/MarkerInfoWindowViewController.swift)\n(Swift).\n\nSee [code samples](/maps/documentation/ios-sdk/code-samples) for information on downloading and running\nthese samples."]]