javascript - 打印时加载 map 标记问题

标签 javascript angularjs node.js google-maps google-maps-api-3

我能够在 map 上指向标记,并且它在浏览器中可见。但是当我打印相同的内容时,标记在 map 上不可见。请帮忙。

<button class="map-print" ng-click="mapprint();">print</button>
[enter image description here][1]<script>
function mapprint(){
    var content = document.getElementById('map_div'); //has to be first. 
    content.style.position = "relative"; 
    content.style.height = contents.firstChild.offsetHeight + "px"; 
    content.style.width = contents.firstChild.offsetWidth + "px"; 
    var win = window.open(); 
    win.document.write(content.innerHTML);
    win.print();
    win.close();    
}

我得到了 map 的打印件。但是无法加载 map 标记

这是我的网页 View

这是我的 map 打印 View

最佳答案

Google Maps JavaScript API 不支持打印。看看官方常见问题解答中的以下答案

https://developers.google.com/maps/faq#print

Printing from the JavaScript API is not supported. This is because printing support is inconsistent across commonly used browsers. We recommend using the Static Maps API for printing purposes.

关于javascript - 打印时加载 map 标记问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44386581/

相关文章:

angularjs - 从指令访问 Controller 范围

node.js - 如何使用 papaparse 将对象数组正确转换为 CSV?

javascript - 用dialog.showSaveDialog实现 promise 拒绝

javascript - AngularJS 中的 ScrollTo 函数

angularjs - 如何在 Jasmine 中模拟 response.headers ('location' )?

javascript - VueJS 无法使用 "/"路由打开主页

JavaScript、JQuery 上一个按钮

javascript - 来自 URL 的 Nodejs 查询不起作用

javascript - 单击 <Link/> 设置 localStorage - Reactjs

javascript - 单击网页中的选项时如何从 "id"向下移动一些像素?