1

I am using the google map api v2. When I go to print the map, the controls are being displayed on the print out. How can I set GLargeMapControl and GMapTypeControl not to print?

I seen in the API there is a GControl Printable constuctor but can not find any information on its usage.

I have tried using these 2 functions:

function Clickheretoprint() { var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; disp_setting+="scrollbars=no,width=650, height=600, left=100, top=25"; var content_vlue = document.getElementById("gm").innerHTML;

var docprint=window.open("","",disp_setting);

docprint.document.open();
docprint.document.write('<html><head><title>Inel

Power System');

docprint.document.write('</head><body

class="gmnoprint print" onLoad="window.print();window.close()">'); docprint.document.write(content_vlue); docprint.document.write(''); docprint.document.close(); docprint.focus(); }

and

function ClickHereToPrint(){ try {

  var oIframe =

document.getElementById('ifrmPrint'); var oContent = document.getElementById('gm').innerHTML; var oDoc = (oIframe.contentWindow || oIframe.contentDocument); if (oDoc.document) oDoc = oDoc.document; oDoc.write("title"); oDoc.write(""); oDoc.write(oContent + ""); oDoc.close(); }

catch(e){

  self.print();

}

}

In the HTML page I have:

var lat, lon, init_zoom; lat = 44.9647979303; lon = -99.84375; init_zoom = 3;
Google Maps Print test

<script type="text/javascript" src="mapscripts.js"></script> </head>

Print

            <div id="bottomDiv" class="clsBottomDiv" align="left">
                <table>
                    <tr>
                        <td>
                            Search for Address:
                          <form onSubmit="return Geocode()">
                            <input id="search" type="text" size="60"

/>

                    </tr>
                </table>
            </div>

        </td>
    </tr>
</table> </div> </body> </html>

I tried giving the iframe a class of gmnoprint also with no luck.

4

1 回答 1

0

只需使用打印样式表 :)

你可以在这里读到所有和它有关的

谷歌已经让你很容易,只需定位类'gmnoprint',你就可以摆脱所有这些东西:)

如果您不想要额外的打印样式表,您可以将此规则添加到现有样式表中:

@media print {
   .gmnoprint {display: none;}
}

或将其内联到您的页面中:

<style>
@media print {
   .gmnoprint {display: none;}
}
</style>
于 2011-01-19T20:44:33.853 回答