Maps Module Reference

New in version 0.0.6.

Control the macOS Maps application using JXA-like syntax.

Classes:

XAMapsApplication(properties)

A class for managing and interacting with Maps.app.

XAMapsDirections(properties)

A class for interacting with directions in Maps.app.

XAMapsDirectionsList(properties[, filter])

A wrapper around a list of directions.

XAMapsSidebarLocation(properties)

A class for interacting with sidebar locations in Maps.app.

XAMapsSidebarLocationList(properties[, filter])

A wrapper around a list of sidebar locations.

XAMapsTab(properties)

A class for interacting with sidebar locations in Maps.app.

XAMapsTabList(properties[, filter])

A wrapper around a list of locations.

class PyXA.apps.Maps.XAMapsApplication(properties)[source]

Bases: XAApplication

A class for managing and interacting with Maps.app.

See also

XAMapsSidebarLocation, XAMapsDirection

New in version 0.0.6.

Methods:

directions_to(destination_address[, ...])

Queries for directions to the destination address, optionally starting from a source address.

drop_pin(latitude, longitude[, name])

Drops at pin at the specified coordinate.

new_tab()

Opens a new tab.

orient_north()

Orients the map with North facing upward.

search(query[, latitude, longitude, exact])

Searches Maps for the given query, centered at the (optional) specified location.

show_address(address)

Centers the map at the specified address.

show_coordinate(latitude, longitude)

Centers the map at the specified coordinate.

sidebar_locations()

Gets a list of sidebar locations.

tabs()

Gets a list of tabs.

toggle_sidebar()

Toggles the sidebar.

zoom_in()

Zoom in on the currently centered location of the map.

zoom_out()

Zoom out on the currently centered location of the map.

Attributes:

sidebar_showing

Whether the sidebar is currently showing.

directions_to(destination_address: str | XAText, source_address: str | XAText | None = None, transport_type: Literal['d', 'driving', 'w', 'walking', 'p', 'pt', 'r', 'public transit', 'transit'] | None = None)[source]

Queries for directions to the destination address, optionally starting from a source address.

If no source address is provided, the current location is used.

Parameters:
  • destination_address (str) – The address to retrieve directions to

  • source_address (Union[str, None], optional) – The address to start the directions from, defaults to None

  • transport_type (Union[Literal["d", "driving", "w", "walking", "p", "pt", "r", "public transit", "transit"], None], optional) – The type of directions to retrieve, defaults to None

New in version 0.0.6.

drop_pin(latitude: float, longitude: float, name: str | None = None)[source]

Drops at pin at the specified coordinate.

Parameters:
  • latitude (float) – The latitude of the coordinate at which to drop a pin

  • longitude (float) – The longitude of the coordinate at which to drop a pin

  • name (Union[str, None], optional) – The name of the pin, defaults to None

New in version 0.0.6.

new_tab()[source]

Opens a new tab.

New in version 0.0.6.

orient_north() XAMapsApplication[source]

Orients the map with North facing upward.

New in version 0.0.6.

search(query: str | XAText, latitude: float | None = None, longitude: float | None = None, exact: bool = True)[source]

Searches Maps for the given query, centered at the (optional) specified location.

Parameters:
  • query (str) – The term to search for

  • latitude (Union[float, None], optional) – The latitude of the location to center the search at, defaults to None

  • longitude (Union[float, None], optional) – The longitude of the location to center the search at, defaults to None

  • exact (bool, optional) – Whether search results must be centered on the specified location versus allowing further away results, defaults to True

New in version 0.0.6.

show_address(address: str)[source]

Centers the map at the specified address.

Parameters:

address (str) – The address to display

New in version 0.0.6.

show_coordinate(latitude: float, longitude: float)[source]

Centers the map at the specified coordinate.

Parameters:
  • latitude (float) – The latitude of the coordinate to display

  • longitude (float) – The longitude of the coordinate to display

New in version 0.0.6.

sidebar_locations() XAMapsSidebarLocationList[source]

Gets a list of sidebar locations.

Returns:

The list of locations

Return type:

XAMapsSidebarLocationList

New in version 0.0.6.

property sidebar_showing: bool

Whether the sidebar is currently showing.

tabs() XAMapsTabList[source]

Gets a list of tabs.

Returns:

The list of tabs

Return type:

XAMapsTabList

New in version 0.0.6.

toggle_sidebar()[source]

Toggles the sidebar.

New in version 0.0.6.

zoom_in() XAMapsApplication[source]

Zoom in on the currently centered location of the map.

New in version 0.0.6.

zoom_out() XAMapsApplication[source]

Zoom out on the currently centered location of the map.

New in version 0.0.6.

class PyXA.apps.Maps.XAMapsDirections(properties)[source]

Bases: XAObject

A class for interacting with directions in Maps.app.

New in version 0.0.6.

Attributes:

destination_address

The ending address of the directions

duration

The duration of the currently selected route from the source address to the destination address

has_tolls

Whether the currently selected route has tolls

has_weather_warnings

Whether there are weather warnings along the currently selected route

source_address

The starting address of the directions

destination_address: str

The ending address of the directions

duration: float

The duration of the currently selected route from the source address to the destination address

has_tolls: bool

Whether the currently selected route has tolls

has_weather_warnings: bool

Whether there are weather warnings along the currently selected route

source_address: str

The starting address of the directions

class PyXA.apps.Maps.XAMapsDirectionsList(properties: dict, filter: dict | None = None)[source]

Bases: XAList

A wrapper around a list of directions.

New in version 0.0.3.

class PyXA.apps.Maps.XAMapsSidebarLocation(properties)[source]

Bases: XAObject

A class for interacting with sidebar locations in Maps.app.

New in version 0.0.6.

Attributes:

description

The description of the location element.

name

The name of the location.

selected

Whether the location element is currently selected.

Methods:

show_directions_to()

property description: str

The description of the location element.

property name: str

The name of the location.

property selected: bool

Whether the location element is currently selected.

show_directions_to()[source]
class PyXA.apps.Maps.XAMapsSidebarLocationList(properties: dict, filter: dict | None = None)[source]

Bases: XAList

A wrapper around a list of sidebar locations.

New in version 0.0.3.

Methods:

name()

name() list[str][source]
class PyXA.apps.Maps.XAMapsTab(properties)[source]

Bases: XASystemEventsUIElement

A class for interacting with sidebar locations in Maps.app.

New in version 0.0.6.

Methods:

close()

Attributes:

properties

All properties of the tab.

close()[source]
property properties: dict

All properties of the tab.

class PyXA.apps.Maps.XAMapsTabList(properties: dict, filter: dict | None = None)[source]

Bases: XASystemEventsUIElementList

A wrapper around a list of locations.

New in version 0.0.3.

Methods:

title()

title() list[str][source]