-
Notifications
You must be signed in to change notification settings - Fork 37
Events list
You can add your own handler for map-related events by calling bind on the OpenHeatMap component. This is the list of the possible events you can hook into, along with the circumstances they’re called in and information that’s passed.
Every handler function must return a value indicating whether the event should continue to be processed by the map component to implement its default behavior. If you didn’t want double-clicking on the map to zoom in for example, you’d attach an event to ‘doubleclick’ and return false. Note – a common bug is returning nothing from your event handler function, which resolves as false and so further processing of the event is abandoned. For example if your ‘click’ handler didn’t return anything then you would see the map failing to re-render as the user panned around by dragging the mouse. Make sure your handlers always return something.
All of the mouse events (click, doubleclick, mousedown, mouseout, mouseover, mouseup) get passed the following information in an object as their first argument:
x – The horizontal position of the mouse cursor in pixels, relative to the left side of the map component
y – The vertical position of the mouse cursor in pixels, relative to the top of the map component
lat – The latitude of the map point under the mouse cursor
lon – The longitude of the map point under the mouse cursor
click – a mouse single click with the left button
datachange – The map values have changed, either a new values file has been loaded or a new frame in the animation is shown
doubleclick – A double click with the left button
error – Called when something goes wrong with the component. The first argument is a string describing the problem
framerender – Called every time the map component is redrawn
mousedown – The left mouse button has been pressed
mouseout – The mouse cursor has left the map area
mouseover – The mouse cursor has moved whilst over the map area
mouseup – The left mouse button has been released
valuesload – An external set of values data has finished loading
viewchange – The user has panned or zoomed the view of the map
waysload – The geometry for the map has completely loaded