# Maps

Applications can launch the Map application with a display showing the results of any query string constructed by using Google Maps Parameters. You can optionally select the map type (satellite or map), traffic overlay, and zoom level. Use this for mapping to a specific location, the results of a local or business search, and even driving directions.

## Objects

This section describes the following object:

- params

### params

Attribute | Type | Description
--- | --- | ---
JSON | location | Optional (lat, lng, acc, age). If specified, Map searches for "query" around this location. Abbreviations are: acc: accuracy in meters (float); optional (increasing this number to 3 or highter may speed up response time) age: age of location fix in seconds lat: latitude in degrees (float) lng: longitude in degrees (float)
layer | string | Optional. Activates selective overlays, currently limited to "t" for traffic or null for no overlay.
query | string | Optional. Well-formed expression complying with the Google Map Parameters specification. The options include at least address, lat/lon, location and business search, or driving directions.
type | string | Optional. Sets the display type, currently limited to "m" for map (default) and "k" for satellite.
zoom | string | Optional. The zoom level value is 1-18, with 18 being the maximum zoom in. Note: The maximum zoom level depends on the region. For some regions, zoom level 18 may not be available.

## Methods

This section describes the following methods:

- open
- launch

### open

Launches the Maps application with an encoded URI that either conforms to the Google Map Parameters specification or maps a location or directions to a location when supplied with the appropriate target string.

Required parameter:

- target, or id plus params

#### Parameters

Parameter | Type | Description
--- | --- | ---
target | string | URL matching the regular expression: (.+.)?google.(com|[a-z]{2}|com?.[a-z]{2})(/maps/m|/maps/m/.*) Or, the target string can be of the form "mapto:location", where location is a well-formed location.
params | object | See the params objects.

#### Return Handling

There are no attributes for return handling.

#### Example using target

>     this.controller.serviceRequest("palm://com.palm.applicationManager", {
>       method:"open",
>       parameters:{target: "mapto: 950 Maude Ave., 94085"}
>     });

#### Example using id plus params

>     this.controller.serviceRequest("palm://com.palm.applicationManager", {
>       method:"open",
>       parameters:{
>           id: "com.palm.app.maps",
>           params: {
>               query: "http://maps.google.com?q=Portland,+OR",
>               type: "k",
>               zoom: "16",
>               layer: "t"
>           }
>       }
>     });

### launch

Launches the Maps application with a JSON object that includes queries and options for zoom, map type, and layers.

Required parameters:

- id
- params

#### Parameters

Parameter | Type | Description
--- | --- | ---
id | string | Set to "com.palm.app.maps".
params | object | See the params objects.

#### Return Handling

There are no attributes for return handling.

#### Example

>     this.controller.serviceRequest("palm://com.palm.applicationManager", {
>       method:"launch",
>       parameters: {
>           id: "com.palm.app.maps",
>           params: {
>               query: "palm, sunnyvale"
>           }
>       }
>     });

## Examples

### Open Command

>     var theParams = {
>       query: "Sunnyvale, CA",
>     };

>     this.controller.serviceRequest("palm://com.palm.applicationManager", {
>       method:"open",
>       parameters: {
>           id: "com.palm.app.maps",
>           params: theParams
>       }
>     });

### Launch Command

>     var theParams = {
>       id:"com.palm.app.maps",
>       params: {mapto: "Sunnyvale, CA"}
>     };

>     this.controller.serviceRequest('palm://com.palm.applicationManager', {
>       method: "launch",
>       parameters: theParams
>     });

### Search for Pizza Around a Specified Location (lat, lng)

>     this.controller.serviceRequest("palm://com.palm.applicationManager", {
>       method: "open",
>       parameters: {
>           id: "com.palm.app.maps",
>           params: {
>               location: {lat: 37.759568992305134, lng: -122.39842414855957, acc: 30},
>               query: "Pizza"
>           }
>       }
>     });

## Sample Code

See Services Sample.