简体   繁体   English

从Internet Explorer打印API生成的Google地图

[英]Printing API-Generated Google Maps from Internet Explorer

Having an odd problem printing an API-generated (V3) Google Map from Internet Explorer 7 & 8. 从Internet Explorer 7和8打印API生成的(V3)Google Map时遇到了奇怪的问题。

I generate my map with JavaScript similar to the following: 我使用类似于以下内容的JavaScript生成地图:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
    var centroid = new google.maps.LatLng(35.9948166667, -83.9781791667);
    var myOptions = {
      disableDefaultUI: true,
      zoom: 12,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: centroid
    };
    var map = new google.maps.Map(document.getElementById("map"), myOptions);
    var marker0 = new google.maps.Marker({
      position: new google.maps.LatLng(36.1102, -83.9208),
      map: map
    });
    var marker1 = new google.maps.Marker({
      position: new google.maps.LatLng(36.001, -83.8646),
      map: map
    });
}
</script>

Typically there are about 25-35 markers on any of my maps. 通常,我的任何地图上都有大约25-35个标记。 These print just great from Safari, Firefox, and Chrome, on both OS X & Windows XP. 在OS X和Windows XP上的Safari,Firefox和Chrome上,这些打印效果都很好。 But, as soon as I try to print from Internet Explorer 7 or 8, the maps go all crazy: they overflow their boundaries that I set in the print CSS and the markers disappear from the map, leaving just a blank spot on the map. 但是,一旦我尝试从Internet Explorer 7或8中进行打印,这些地图就会发疯:它们溢出了我在打印CSS中设置的边界,并且标记从地图上消失了,在地图上只留下了一个空白点。

Anyone encountered this/know how to proceed? 任何人都遇到此/知道如何进行?

TIA. TIA。

IIRC, you'll have to use the Google Static Maps API if you want printer friendly maps. IIRC,如果要打印友好的地图,则必须使用Google Static Maps API。

It should be pretty easy to build the Static Maps API URL request string from the LatLng or your markers. 从LatLng或标记构建Static Maps API URL请求字符串应该非常容易。 One caveat is that the URL is limited to 2048 characters including any character escapes, this will limit how many markers you can have on the map at one time. 一个警告是,URL限制为2048个字符,包括任何字符转义符,这将限制您一次可以在地图上具有多少个标记。

[Edit] In the Javascript API, markers have the class 'gmnoprint', which disables them from showing up on the printed rendering. [编辑]在Javascript API中,标记的类为'gmnoprint',使标记无法显示在打印的渲染图上。 You can iterate through the markers and remove this class, which should allow them to be printed on the page. 您可以遍历标记并删除此类,这应允许它们被打印在页面上。 As far as I know, this will not work for the direction lines. 据我所知,这不适用于方向线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM