function openFullscreen(elem) {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.webkitRequestFullscreen) { /* Safari */
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { /* IE11 */
elem.msRequestFullscreen();
}
}
//when you tap on screen then is opened in fullscreen mode
map.addEventListener('tap', () => {
openFullscreen(document.documentElement); //open in fullscreen mode whole HTML document
//or
//openFullscreen(document.getElementById('mapContainer')); //open in fullscreen mode only map
});
1条答案
按热度按时间lyr7nygr1#
我认为这个问题与HERE API无关,而是与Javascript本身有关。
我在https://www.w3schools.com/howto/howto_js_fullscreen.asp和Failed to execute 'requestFullScreen' on 'Element': API can only be initiated by a user gesture上找到了解决方案
测试的简单代码:
以上示例在此处实现:https://jsfiddle.net/ybj57ovc/1/