A stylised map which can be added to a web page one or more times.

You must call the attach method to actually show an interactive map on a web page.

Adding to Page

Calculating Routes

Other

Adding to Page

  • Creates a MapView based on this map, adding it to the specified element.

    Parameters

    Returns MapView

    The new MapView contained within the specified element.

    The resulting map view will fill the container element specified, and automatically resize with it.

    This function can be called multiple times. Note that some browsers (especially on mobile devices) cannot display more than one map view simultaneously.

Calculating Routes

  • Calculates the route from one location to one or more destination locations.

    Parameters

    • origin: Coordinates | MapPoint

      The starting position of the route as some coordinates or a map point.

    • destination: Coordinates | MapPoint | Iterable<Coordinates | MapPoint>

      The destination of the route as some coordinates or a map point. An Iterable returning multiple instances of these types can be provided instead, which causes the route to terminate at the closest (via the paths) destination.

    • Optionaloptions: RouteOptions

      Optional route options which can be used to customise the final route.

    Returns Promise<Route>

    The route between the specified origin and the (closest) destination.

    The routing information is lazily-downloaded the first time this method is called. Once the download is complete, subsequent routes will be calculated instantaneously.

    Calculating routes from the same origin with the same options repeatedly has a special optimisation: this allows e.g. finding the distance from the user's location to a list of POIs to perform quite quickly. This optimisation is reset each time the origin or route options changes.

    Will throw an error if the routing information can't be loaded, or if a route is unavailable for the chosen origin and destination.

  • Creates a reactive route that automatically updates when the origin position changes.

    Parameters

    • origin: PositionProvider

      The position provider (e.g., user location marker)

    • destination: Coordinates | MapPoint | Iterable<Coordinates | MapPoint>

      The destination coordinates or map point. An Iterable returning multiple instances of these types can be provided instead, which causes the route to terminate at the closest (via the paths) destination.

    • Optionaloptions: RouteOptions

      Optional route calculation options

    Returns ReactiveRoute

    A reactive route instance

    The reactive route will automatically recalculate when the origin location changes. Multiple shapes can subscribe to the same reactive route to share calculation results.

Other

  • Creates a Map instance using the given ID.

    Parameters

    • id: string

    Returns Promise<Map>