Search

Events

MapWeave lets you respond to various events fired by the map, which can be triggered either by user interaction or by items changing on the map. To attach an event handler to an event, add the event handler prop in the MapWeave tag.

When an event fires, any attached event handlers are passed a single object containing all the details of the event.

If present, calling the preventDefault() function in the event handler will prevent the event's default action.

ChangeReason

ChangeReason "auto" | "user"

The reason the event was fired:

  • 'auto' - The event was triggered by internal MapWeave state.
  • 'user' - The event was triggered by user action.

ClickEvent

An object to describe the event fired when the user clicks or taps on the map.

string

The id of the targeted item, or null for the background map.

The targeted item, or null for the background map.

Layer<any, any, any>

The layer of the targeted item, or null for the background map.

The geographic position and height above sea level of the event, or null if not a valid position on the map.

number

The distance from the left of the canvas to the pointer position in pixels.

number

The distance from the top of the canvas to the pointer position in pixels.

DragEndEvent

An object to describe the event fired when the drag is finished and pointer is released, or when the drag is canceled.

string

The id of the targeted item, or null for the background map.

The targeted item, or null for the background map.

Layer<any, any, any>

The layer of the targeted item, or null for the background map.

The geographic position and height above sea level of the event, or null if not a valid position on the map.

number

The distance from the left of the canvas to the pointer position in pixels.

number

The distance from the top of the canvas to the pointer position in pixels.

DragMoveEvent

An object to describe the event fired continuously as the cursor moves during a drag.

string

When dragging a tracker node, the associated entity id of this trajectory tracker. Otherwise null.

string

The id of the targeted item, or null for the background map.

The targeted item, or null for the background map.

Layer<any, any, any>

The layer of the targeted item, or null for the background map.

The geographic position and height above sea level of the event, or null if not a valid position on the map.

Date

When dragging a tracker node, the time corresponding to the node's position along the trajectory. Otherwise null.

number

The distance from the left of the canvas to the pointer position in pixels.

number

The distance from the top of the canvas to the pointer position in pixels.

DragStartEvent

An object to describe the event fired when a drag is started. Default action: Creates a dragger.

readonly
boolean

If the default action was prevented.

string

The id of the targeted item, or null for the background map.

The targeted item, or null for the background map.

Layer<any, any, any>

The layer of the targeted item, or null for the background map.

The geographic position and height above sea level of the event, or null if not a valid position on the map.

number

The distance from the left of the canvas to the pointer position in pixels.

number

The distance from the top of the canvas to the pointer position in pixels.

Can be called to prevent the default action of the event.

Returns void

HoverEvent

An object to describe the event fired when the user hovers over the map.

string

The id of the targeted item, or null for the background map.

The targeted item, or null for the background map.

Layer<any, any, any>

The layer of the targeted item, or null for the background map.

The geographic position and height above sea level of the event, or null if not a valid position on the map.

number

The distance from the left of the canvas to the pointer position in pixels.

number

The distance from the top of the canvas to the pointer position in pixels.

ViewChangeEvent

An object to describe the event fired when the map view changes.

The new view state after the change.

The reason the view changed.

Terms of use

These terms do not alter or supersede any existing agreements between you (or your employer) and us.

By accessing or using any Content you agree to be bound by these Terms of Use. Please review these terms carefully before using the website.

The contents of this website, including but not limited to any text, code samples, API references, schemas, interactive tools, and other materials (collectively, the 'Content'), are made available for informational and internal evaluation purposes only. All intellectual property rights in the Content are reserved. No licence is granted to use the Content for any commercial purpose, or to copy, distribute, modify, reverse-engineer, or incorporate any part of the Content into any product or service, without our prior written consent.

This Content is provided “as is” and “as available,” without any representations, warranties, or guarantees of any kind, whether express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, non-infringement, or accuracy. To the fullest extent permitted by applicable law, we expressly exclude and disclaim all implied warranties, conditions, and other terms that might otherwise be implied.

We disclaim all liability for any loss or damage, whether direct, indirect, incidental, consequential, or otherwise, arising from any reliance placed on the Content or from your use of it, to the fullest extent permitted by applicable law. By continuing to access or use the Content, you acknowledge and agree to these terms.