Angular 谷歌地图

Angular 谷歌地图,angular,maps,agm,Angular,Maps,Agm,我已经用agm组件实现了google地图。我设法在上面显示wms层。应用后,我正在尝试打印地图图像。当我打印图像时,谷歌地图会出现在打印预览中,但wms图层没有出现。 printMap(){ var contents=window.document.getElementById(“gmap”); var frame1=document.createElement('iframe'); frame1.name=“frame1”; frame1.style.position=“绝对”; frame

我已经用agm组件实现了google地图。我设法在上面显示wms层。应用后,我正在尝试打印地图图像。当我打印图像时,谷歌地图会出现在打印预览中,但wms图层没有出现。

printMap(){
var contents=window.document.getElementById(“gmap”);
var frame1=document.createElement('iframe');
frame1.name=“frame1”;
frame1.style.position=“绝对”;
frame1.style.top=“-1000000px”;
document.body.appendChild(frame1);
var frameDoc=(frame1.contentWindow)?frame1.contentWindow:(frame1.contentDocument['document'])?frame1.contentDocument['document']:'';
frameDoc.document.open();
frameDoc.document.write(“”);
frameDoc.document.write(`.agm映射容器内部{高度:800px;宽度:800px;位置:绝对;}`);
frameDoc.document.write(contents.innerHTML);
frameDoc.document.write(“”);
frameDoc.document.close();
setTimeout(函数(){
window.frames[“frame1”].focus();
window.frames[“frame1”].print();
document.body.removeChild(frame1);
}, 500);
返回false;
}
printMap() {
    var contents = window.document.getElementById("gmap");

    var frame1 = document.createElement('iframe');
    frame1.name = "frame1";
    frame1.style.position = "absolute";
    frame1.style.top = "-1000000px";
    document.body.appendChild(frame1);
    var frameDoc = (frame1.contentWindow) ? frame1.contentWindow : (frame1.contentDocument['document']) ? frame1.contentDocument['document']:'';
    frameDoc.document.open();
    frameDoc.document.write('<html><head>');
    frameDoc.document.write(`<style>.agm-map-container-inner{height: 800px;width: 800px;position:absolute;}</style></head><body>`);
    frameDoc.document.write(contents.innerHTML);
    frameDoc.document.write('</body></html>');
    frameDoc.document.close();
    setTimeout(function () {
        window.frames["frame1"].focus();
        window.frames["frame1"].print();
        document.body.removeChild(frame1);
    }, 500);
    return false;
}

<div id="gmap" class="col-md-8">
    <agm-map 
    [latitude]="lat" 
    [longitude]="lng" 
    [zoom]="zoom"
    (mapClick)="addMarker($event)"
    (mapReady)="onMapReady($event)"
    >
        <agm-data-layer *ngIf="geoJsonObject" [geoJson]="geoJsonObject" [style]="styleFunc"></agm-data-layer>
        <agm-marker [latitude]="lat" [longitude]="lng" [markerDraggable]="true"
        (dragEnd)="markerDragEnd($event)" [agmFitBounds]="true">
        </agm-marker>
    </agm-map>
</div>