This is a part of the JavaScript code I use:
infobox.setLocation(e.target.getLocation());
infobox.setHtmlContent(myHtmlContent);
infobox.setOptions({
showPointer: false,
showCloseButton: true,
offset: new Microsoft.Maps.Point(0, 25),
visible: true
});
Is it possible that the 'showCloseButton' option doesn't work when using setHtmlContent? Or am I missing something?
update: By adding this code manually I'm able to close the infobox, but I'm not sure if this is the correct way to close the infobox:
'<a class="infobox-close" href="javascript:closeInfobox()">x</a>'
and the Javascript function:
function closeInfobox() {
infobox.setOptions({ visible: false });
}
The show close button is only for when you are using the default infobox template. When you use custom HTML that functionality is overridden. Your approach of using a link that calls JavaScript to close the infobox is the correct approach to take.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.