if(UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)){UIApplication.shared.openURL(URL(string:"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic")!)}else{print("Can't use comgooglemaps://");}
Objective-C
if([[UIApplicationsharedApplication]canOpenURL:[NSURLURLWithString:@"comgooglemaps://"]]){[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:@"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic"]];}else{NSLog(@"Can't use comgooglemaps://");}
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eUse Universal Links (\u003ccode\u003ehttps://www.google.com/maps/\u003c/code\u003e) for seamless integration with Google Maps on iOS 9 and later, or the \u003ccode\u003ecomgooglemaps://\u003c/code\u003e URL scheme for iOS-specific features.\u003c/p\u003e\n"],["\u003cp\u003eUtilize URL parameters to control map display, search, directions, and Street View within the Google Maps app.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecomgooglemaps-x-callback://\u003c/code\u003e scheme allows your app to receive callbacks when Google Maps completes an action.\u003c/p\u003e\n"],["\u003cp\u003eLeverage the \u003ccode\u003ecomgooglemapsurl://\u003c/code\u003e scheme to open desktop Google Maps URLs (\u003ccode\u003emaps.google.com\u003c/code\u003e, etc.) directly in the iOS app.\u003c/p\u003e\n"],["\u003cp\u003eAlways check if the Google Maps app is installed (\u003ccode\u003eUIApplication.shared.canOpenURL\u003c/code\u003e) before attempting to launch it using a URL scheme.\u003c/p\u003e\n"]]],[],null,["On devices running iOS 9 and later, you can use\n[Universal Links](#universal-links-and-google-maps) to launch Google\nMaps when you have a Google Maps URL.\n\nYou can use the Google Maps URL scheme to launch the\n[Google Maps app for iOS](https://itunes.apple.com/app/id585027354)\nand perform searches, get direction\nrequests, and display map views. When you launch Google Maps, your bundle\nidentifier is automatically sent as part of the request.\n\nYou don't need a Google API key to use the Google Maps URL scheme.\n| **Note:** [Maps URLs](/maps/documentation/urls/guide) let you build a universal, cross-platform URL to launch Google Maps and perform searches, get directions, display map views, and display panoramic images. It is recommended that you use the cross-platform **[Maps URLs](/maps/documentation/urls/guide)** to launch Google Maps, since these universal URLs allow for broader handling of the maps requests no matter which platform the user is on. You should only use the iOS-specific Maps URL Scheme for features that may only be functional on a mobile platform (for example, turn-by-turn navigation).\n\nUniversal Links and Google Maps\n\nGoogle Maps for iOS supports\n[Universal\nLinks](https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html) on devices running iOS 9 or later.\n\nIf your URL matches the following regular expression, and the device is running\niOS 9 or later, you may want to consider using the openURL: method directly. \n\n (http(s?)://)?\n ((maps\\.google\\.{TLD}/)|\n ((www\\.)?google\\.{TLD}/maps/)|\n (goo.gl/maps/))\n .*\n\nFor example,\n\n\u003cbr /\u003e\n\nSwift\n\n\u003cbr /\u003e\n\n UIApplication.shared.openURL(URL(string:\"https://www.google.com/maps/@42.585444,13.007813,6z\")!)\n\n\u003cbr /\u003e\n\nObjective-C\n\n\u003cbr /\u003e\n\n [[UIApplication sharedApplication] openURL:\n [NSURL URLWithString:@\"https://www.google.com/maps/@42.585444,13.007813,6z\"]];\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nOverview\n\nA URL scheme lets you launch an iOS application from another iOS app\nor a web application. You can set options in the URL that are passed to the\nlaunched application. The Google Maps app for iOS supports the following URL\nschemes:\n\n- `comgooglemaps://` - This scheme lets you launch the Google Maps app\n for iOS and perform one of several actions:\n\n - Display a map at a specified location and zoom level.\n - Search for locations or places, and display them on a map.\n - Request directions from one location to another. Directions can be returned for four modes of transportation: driving, walking, bicycling and public transit.\n - Add navigation to your app.\n- `comgooglemapsurl://` - This scheme lets you launch the Google Maps app\n for iOS using a URL derived from the desktop Google Maps website. This means\n that you can give your users a mobile experience rather than\n loading the Google Maps website.\n\n - The original URL can be for `maps.google.com`, or for `google.com/maps`, or using any valid top-level country domain instead of `com`. You can also pass on `goo.gl/maps` redirection URLs.\n\nLaunch the Google Maps app for iOS and perform a specific function **Note:** Beginning with iOS 9, your app must declare the URL schemes that it will open. See [Getting Started](/maps/documentation/ios-sdk/start#step_7_declare_the_url_schemes_used_by_the_api) for more information.\n\nTo launch the Google Maps app for iOS and optionally perform one of the\nsupported functions, use a URL scheme of the following form: \n\n```text\ncomgooglemaps://?parameters\n```\n\nParameters are described in detail later in this document.\n\nCheck the availability of the Google Maps app on the device\n\nBefore you present one of these URLs to a user in your app you should first\nverify that the application is installed. Your app can check that the URL\nscheme is available with the following code:\n\n\u003cbr /\u003e\n\nSwift\n\n\u003cbr /\u003e\n\n UIApplication.shared.canOpenURL(URL(string:\"comgooglemaps://\")!)\n\n\u003cbr /\u003e\n\nObjective-C\n\n\u003cbr /\u003e\n\n [[UIApplication sharedApplication] canOpenURL:\n [NSURL URLWithString:@\"comgooglemaps://\"]];\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nFor example, to display a map of Central Park in New York, you can use the\nfollowing code:\n\n\u003cbr /\u003e\n\nSwift\n\n\u003cbr /\u003e\n\n if (UIApplication.shared.canOpenURL(URL(string:\"comgooglemaps://\")!)) {\n UIApplication.shared.openURL(URL(string:\n \"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic\")!)\n } else {\n print(\"Can't use comgooglemaps://\");\n }\n\n\u003cbr /\u003e\n\nObjective-C\n\n\u003cbr /\u003e\n\n if ([[UIApplication sharedApplication] canOpenURL:\n [NSURL URLWithString:@\"comgooglemaps://\"]]) {\n [[UIApplication sharedApplication] openURL:\n [NSURL URLWithString:@\"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic\"]];\n } else {\n NSLog(@\"Can't use comgooglemaps://\");\n }\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDisplay a map\n\nUse the URL scheme to display the map at a specified zoom level and location.\nYou can also overlay other views on top of your map, or display Street View imagery.\n\n**Parameters**\n\nAll of the following parameters are optional. If no parameters are set, the\nURL scheme will launch the Google Maps app for iOS.\n\n- `center`: This is the map viewport center point. Formatted as a comma separated string of `latitude,longitude`.\n- `mapmode`: Sets the kind of map shown. Can be set to: `standard` or `streetview`. If not specified, the current application settings will be used.\n- `views`: Turns specific views on/off. Can be set to: `satellite`, `traffic`, or `transit`. Multiple values can be set using a comma-separator. If the parameter is specified with no value, then it will clear all views.\n- `zoom`: Specifies the zoom level of the map.\n\nThis example URL displays the map centered on New York at zoom 14 with the\ntraffic view on: \n\n comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic\n\nSome additional examples are: \n\n comgooglemaps://?center=37.788463,-122.392545&zoom=12\n\n```text\ncomgooglemaps://?center=46.414382,10.013988&mapmode=streetview\n```\n\nSearch\n\nUse this scheme to display search queries in a specified viewport location.\n\n**Parameters**\n\nIn addition to the parameters used to display a map, Search supports the `q`\nparameter.\n\n- `q`: The query string for your search.\n\nThis example URL to searches for \"Pizza\" around the specified location: \n\n comgooglemaps://?q=Pizza¢er=37.759748,-122.427135\n\nSome additional examples are: \n\n comgooglemaps://?q=Steamers+Lane+Santa+Cruz,+CA¢er=37.782652,-122.410126&views=satellite,traffic&zoom=15\n\n```text\ncomgooglemaps://?q=Google+Japan,+Minato,+Tokyo,+Japan¢er=35.660888,139.73073&zoom=15&views=transit\n```\n\nDisplay directions\n\nUse this scheme to request and display directions between two locations.\nYou can also specify the transportation mode.\n\n**Parameters**\n\n- `saddr`: Sets the starting point for directions searches. This can be a latitude,longitude or a query formatted address. If it is a query string that returns more than one result, the first result will be selected. If the value is left blank, then the user's current location will be used.\n- `daddr`: Sets the end point for directions searches. Has the same format and behavior as `saddr`.\n- `directionsmode`: Method of transportation. Can be set to: `driving`, `transit`, `bicycling` or `walking`.\n\nThe example URL displays transit directions between Google NYC and JFK Airport: \n\n comgooglemaps://?saddr=Google+Inc,+8th+Avenue,+New+York,+NY&daddr=John+F.+Kennedy+International+Airport,+Van+Wyck+Expressway,+Jamaica,+New+York&directionsmode=transit\n\nSome additional examples are: \n\n comgooglemaps://?saddr=Google,+1600+Amphitheatre+Parkway,+Mountain+View,+CA+94043&daddr=Google+Inc,+345+Spear+Street,+San+Francisco,+CA¢er=37.422185,-122.083898&zoom=10\n\n```carbon\ncomgooglemaps://?saddr=2025+Garcia+Ave,+Mountain+View,+CA,+USA&daddr=Google,+1600+Amphitheatre+Parkway,+Mountain+View,+CA,+United+States¢er=37.423725,-122.0877&directionsmode=walking&zoom=17\n```\n\nAdd navigation to your app\n\nLaunching Google Maps app for iOS with a directions request\ngives your users access to turn-by-turn navigation from your app. You can use\nthe `comgooglemaps://` URL scheme.\n\nLaunch the Google Maps app for iOS from a Google Maps desktop URL\n\nIf your app has access to a pre-existing Google Maps URL, such as on a web page\nor in a database, you can use this scheme to open the URL in the Google Maps app\nfor iOS, thus offering your users the best mobile experience.\n\n- Replace the `http://` or `https://` scheme with `comgooglemapsurl://`.\n\nSupported Google Maps URL formats\n\nThe `comgooglemapsurl://` scheme supports URLs that match this regular\nexpression, where `{TLD}` refers to any valid top-level country domain. Line\nbreaks are added for clarity: \n\n (http(s?)://)?\n ((maps\\.google\\.{TLD}/)|\n ((www\\.)?google\\.{TLD}/maps/)|\n (goo.gl/maps/))\n .*\n\nCheck the availability of the Google Maps app\n\nFirst verify that the Google Maps app for iOS is available on the device, and\nsupports the URL scheme:\n\n\u003cbr /\u003e\n\nSwift\n\n\u003cbr /\u003e\n\n UIApplication.shared.canOpenURL(URL(string:\"comgooglemapsurl://\")!)\n\n\u003cbr /\u003e\n\nObjective-C\n\n\u003cbr /\u003e\n\n [[UIApplication sharedApplication] canOpenURL:\n [NSURL URLWithString:@\"comgooglemapsurl://\"]];\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nExamples\n\n**Example of a generic Google Maps URL:**\n\nOriginal Google Maps URL: \n\n```objective-c\nhttps://www.google.com/maps/preview/@42.585444,13.007813,6z\n```\n\nUsing the URL scheme: \n\n comgooglemapsurl://www.google.com/maps/preview/@42.585444,13.007813,6z\n\n**Example of a generic Google Maps URL:**\n\nOriginal Google Maps URL: \n\n```objective-c\nhttps://maps.google.com/?q=@37.3161,-122.1836\n```\n\nUsing the URL scheme: \n\n comgooglemapsurl://maps.google.com/?q=@37.3161,-122.1836"]]