Here Maps JS 中可以使用哪些事件?
What events can be used in Here Maps JS?
我正在寻找 here maps js 的文档,它很差,但是我找不到任何关于哪些事件可以用于哪个“对象”的信息。
当我想在 DomIcon 上添加事件侦听器以及在集群提供程序 (H.clustering.Provider) 上添加其他事件侦听器时,我遇到了两个问题。
有我使用的事件(元素可以是H.map.DomIcon或H.clustering.Provider):
element.addEventListener('pointermove', this.invokeEvent); <-- working for cluster Provider
element.addEventListener('pointerdown', this.invokeEvent);
element.addEventListener('mousedown', this.invokeEvent);
element.addEventListener('touchstart', this.invokeEvent);
element.addEventListener('mouseup', this.invokeEvent);
element.addEventListener('touchend', this.invokeEvent);
element.addEventListener('pointerup', this.invokeEvent);
element.addEventListener('mouseenter', this.invokeEvent);
element.addEventListener('touchenter', this.invokeEvent);
element.addEventListener('pointerenter', this.invokeEvent);
element.addEventListener('mouseleave', this.invokeEvent);
element.addEventListener('touchleave', this.invokeEvent);
element.addEventListener('pointerleave', this.invokeEvent);
element.addEventListener('pointercancel', this.invokeEvent);
element.addEventListener('touchcancel', this.invokeEvent);
element.addEventListener('mouseover', this.invokeEvent); <-- working for dom icon
element.addEventListener('mouseout', this.invokeEvent); <-- working for dom icon
element.addEventListener('tap', this.invokeEvent); <-- working for dom icon and cluster provider
我不知道去哪里找文档或者我做错了什么?对我来说最重要的是找到为 H.clustering.Provider
监听 mouseover
和 mouseout
的事件
请阅读documentation for map object events :
MapEvents enables the events functionality on the map and on map
objects. The class makes it possible to listen to events on map
objects such as markers, polylines, polygons, circles and on the map
object itself. Events are triggered by user interaction, for example
clicking or tapping on the map. Please check the Events Summary
section for the list of events fired by this class and by the map
objects.
您要找的事件是pointerenter和pointerleave
示例:
// prerequisites: mapInstance and marker is initialized
mapInstance.addObject(marker);
var mapevts = new H.mapevents.MapEvents(mapInstance);
// add listener to map
mapInstance.addEventListener('pointermove', function(e) {...});
// add listener to the marker
marker.addEventListener('pointerenter', function(e) {...});
marker.addEventListener('pointerleave', function(e) {...});
请给Marker、DomMarker等添加监听器,不要给Icon或DomIcon。有时向某些 H.map.Goup 添加地图对象很有用,然后只为该组添加一次侦听器,然后它应该适用于该组中的所有地图对象。
你是对的,也可以将相同的事件侦听器添加到基于 H.map.provider 的对象,例如cluster Provider,但似乎还没有记录这种可能性。
我正在寻找 here maps js 的文档,它很差,但是我找不到任何关于哪些事件可以用于哪个“对象”的信息。 当我想在 DomIcon 上添加事件侦听器以及在集群提供程序 (H.clustering.Provider) 上添加其他事件侦听器时,我遇到了两个问题。
有我使用的事件(元素可以是H.map.DomIcon或H.clustering.Provider):
element.addEventListener('pointermove', this.invokeEvent); <-- working for cluster Provider
element.addEventListener('pointerdown', this.invokeEvent);
element.addEventListener('mousedown', this.invokeEvent);
element.addEventListener('touchstart', this.invokeEvent);
element.addEventListener('mouseup', this.invokeEvent);
element.addEventListener('touchend', this.invokeEvent);
element.addEventListener('pointerup', this.invokeEvent);
element.addEventListener('mouseenter', this.invokeEvent);
element.addEventListener('touchenter', this.invokeEvent);
element.addEventListener('pointerenter', this.invokeEvent);
element.addEventListener('mouseleave', this.invokeEvent);
element.addEventListener('touchleave', this.invokeEvent);
element.addEventListener('pointerleave', this.invokeEvent);
element.addEventListener('pointercancel', this.invokeEvent);
element.addEventListener('touchcancel', this.invokeEvent);
element.addEventListener('mouseover', this.invokeEvent); <-- working for dom icon
element.addEventListener('mouseout', this.invokeEvent); <-- working for dom icon
element.addEventListener('tap', this.invokeEvent); <-- working for dom icon and cluster provider
我不知道去哪里找文档或者我做错了什么?对我来说最重要的是找到为 H.clustering.Provider
mouseover
和 mouseout
的事件
请阅读documentation for map object events :
MapEvents enables the events functionality on the map and on map objects. The class makes it possible to listen to events on map objects such as markers, polylines, polygons, circles and on the map object itself. Events are triggered by user interaction, for example clicking or tapping on the map. Please check the Events Summary section for the list of events fired by this class and by the map objects.
您要找的事件是pointerenter和pointerleave
示例:
// prerequisites: mapInstance and marker is initialized
mapInstance.addObject(marker);
var mapevts = new H.mapevents.MapEvents(mapInstance);
// add listener to map
mapInstance.addEventListener('pointermove', function(e) {...});
// add listener to the marker
marker.addEventListener('pointerenter', function(e) {...});
marker.addEventListener('pointerleave', function(e) {...});
请给Marker、DomMarker等添加监听器,不要给Icon或DomIcon。有时向某些 H.map.Goup 添加地图对象很有用,然后只为该组添加一次侦听器,然后它应该适用于该组中的所有地图对象。
你是对的,也可以将相同的事件侦听器添加到基于 H.map.provider 的对象,例如cluster Provider,但似乎还没有记录这种可能性。