The maps URL scheme is used to show geographical locations and to generate driving directions between two points. If your application includes address or location information, you can use map links to forward that information to the Maps application on iOS and the Google Maps website on other platforms.
Unlike some schemes, map URLs do not start with a “maps” scheme identifier. Instead, map links are specified as regular http
links but are targeted at the Google Maps servers. The following examples show the strings you would use in Safari and in a native application to show a map of the city of Cupertino, California.
HTML link:
<a href="http://maps.google.com/maps?q=cupertino">Cupertino</a> |
Native application URL string:
http://maps.google.com/maps?q=cupertino |
The following examples show the strings you would use to provide driving directions between San Francisco and Cupertino:
HTML link:
<a href="http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino">Directions</a> |
Native application string:
http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino |
iOS Note: If the Maps application is not installed on the device, opening a map URL forwards the request to the Google Maps website.
Although the Maps application supports many of the Google Maps parameters and queries, it does not support them all. The rules for creating a valid map link are as follows:
The domain must be google.com
and the subdomain must be maps
or ditu
.
The path must be /
, /maps
, /local
, or /m
if the query contains site
as the key and local
as the value.
The path cannot be /maps/*
.
All parameters must be supported. See Table 1 for list of supported parameters.
A parameter cannot be q=*
if the value is a URL (so KML is not picked up).
The parameters cannot include view=text
or dirflg=r
.
Table 1 lists the parameters supported by iOS along with a brief description of each. For a complete description of these parameters, see Google Map Parameters.
Parameter | Notes |
---|---|
q= | The query parameter. This parameter is treated as if it had been typed into the query box by the user on the maps.google.com page. |
near= | The location part of the query. |
ll= | The latitude and longitude points (in decimal format, comma separated, and in that order) for the map center point. |
sll= | The latitude and longitude points from which a business search should be performed. |
spn= | The approximate latitude and longitude span. |
sspn= | A custom latitude and longitude span format used by Google. |
t= | The type of map to display. |
z= | The zoom level. |
saddr= | The source address, which is used when generating driving directions |
daddr= | The destination address, which is used when generating driving directions. |
latlng= | A custom ID format that Google uses for identifying businesses. |
cid= | A custom ID format that Google uses for identifying businesses. |
Last updated: 2009-06-17