如何勾勒“关闭信息泡沫" HERE Maps Javascript API中的事件 [英] How to hook into the "close infobubble" event in HERE maps Javascript API
问题描述
我可以使用HERE Maps Javascript API创建信息气泡-例如从它们的
I can create infobubbles using the HERE maps Javascript API - eg from their documentation:
function addInfoBubble(map) {
map.set('center', new nokia.maps.geo.Coordinate(53.430, -2.961));
map.setZoomLevel(7);
var infoBubbles = new nokia.maps.map.component.InfoBubbles(),
TOUCH = nokia.maps.dom.Page.browser.touch,
CLICK = TOUCH ? 'tap' : 'click',
container = new nokia.maps.map.Container();
container.addListener(CLICK, function (evt) {
infoBubbles.openBubble(evt.target.html, evt.target.coordinate);
}, false);
map.components.add(infoBubbles);
map.objects.add(container);
addMarkerToContainer(container, [53.439, -2.221],
'<div><a href=\'http://www.mcfc.co.uk\' >Manchester City</a>' +
'</div><div >City of Manchester Stadium<br>Capacity: 48,000</div>');
addMarkerToContainer(container, [53.430, -2.961],
'<div ><a href=\'http://www.liverpoolfc.tv\' >Liverpool</a>' +
'</div><div >Anfield<br>Capacity: 45,362</div>');
}
function addMarkerToContainer(container, coordinate, html) {
var marker = new nokia.maps.map.StandardMarker(
coordinate,
{html: html}
);
container.objects.add(marker);
}
我想了解infobubble的close事件.我意识到我可以使用jQuery查找包含关闭按钮的范围(检查标记,我相信它具有类nm_bubble_control_close
),然后在单击时执行某些操作.但是我认为会有一个内置事件可以使用.
I would like to hook into the close event of the infobubble. I realise I could use jQuery to find the span that contains the close button (examining the markup, I believe it has the class nm_bubble_control_close
) and do something when this is clicked. However I thought there would be a built-in event that I could use.
有人知道关闭信息气泡时是否会触发内置事件吗?我在文档中找不到任何内容.
Does anyone know if there is a built-in event that fires when the infobubble is closed? I can't find anything in the documentation.
推荐答案
AFAIK没有内置事件,也没有可以观察到的相关属性.
AFAIK there is no built-in event, there's also no related property which may be observed.
可能的解决方法:
用自定义函数覆盖内置的close
方法:
Possible workaround:
override the built-in close
-method with a custom function:
container.addListener(CLICK, function (evt) {
var b = infoBubbles.openBubble(evt.target.html, evt.target.coordinate),
c = b.close;
b.close = function(){
//do what you want to
alert('bubble will be closed');
//execute the original close-method
c.apply(b)
}
}, false);
这篇关于如何勾勒“关闭信息泡沫" HERE Maps Javascript API中的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!