Google maps api 3 谷歌地图api3-缩放更改时隐藏/显示多边形

Google maps api 3 谷歌地图api3-缩放更改时隐藏/显示多边形,google-maps-api-3,zooming,polygon,Google Maps Api 3,Zooming,Polygon,我有一个测试页面,我想在加载页面时显示一个多边形,但当访问者达到缩放级别>13时将其删除 我已经在“查看源代码”的顶部以及底部的“可见”参数中注释掉了我的尝试 顺便说一句,如果我插入DOCTYPE,地图不会显示 TIA获取此方面的任何帮助。由于地图没有大小,因此您的页面在显示时不会没有DOCTYPE,应为: <div id="map" style="width: 480px; height: 480px;"></div> 代码片段: 函数初始化(){ var

我有一个测试页面,我想在加载页面时显示一个多边形,但当访问者达到缩放级别>13时将其删除

我已经在“查看源代码”的顶部以及底部的“可见”参数中注释掉了我的尝试

顺便说一句,如果我插入DOCTYPE,地图不会显示


TIA获取此方面的任何帮助。

由于地图没有大小,因此您的页面在显示时不会没有DOCTYPE,应为:

    <div id="map" style="width: 480px; height: 480px;"></div>

代码片段:

函数初始化(){
var map=new google.maps.map(document.getElementById(“map”){
缩放:11,
中心:新google.maps.LatLng(38.4,-75.2),
mapTypeId:google.maps.mapTypeId.ROADMAP
});
var poly=new google.maps.Polygon({
路径:区域边界1,
冲程重量:1,
填充颜色:'#55FF55',
填充不透明度:0.3
});
poly.setMap(map);
google.maps.event.addListener(映射,“zoom_changed”,函数(){
如果(map.getZoom()>13)poly.setMap(null);
else poly.setMap(map);
});
}
google.maps.event.addDomListener(窗口“加载”,初始化);
变量AreaBoundary1=[
新google.maps.LatLng(38.359476783305,-75.214501841143),
新的google.maps.LatLng(38.362345692658,-75.213715263721),
新的google.maps.LatLng(38.367366296974,-75.239013654585),
新的google.maps.LatLng(38.375427394827,-75.235459756599),
新的google.maps.LatLng(38.375228242261,-75.234478037591),
新google.maps.LatLng(38.375273400367,-75.233228514797),
新的google.maps.LatLng(38.375616016941,-75.231891574705),
新google.maps.LatLng(38.375936006851,-75.231339272304),
新的google.maps.LatLng(38.376233242401,-75.230990324745),
新的google.maps.LatLng(38.377330945634,-75.230379285494),
新的google.maps.LatLng(38.378245589651,-75.22973977276),
新的google.maps.LatLng(38.378680054926,-75.22924504172),
新的google.maps.LatLng(38.378862912696,-75.228896215845),
新google.maps.LatLng(38.379090992824,-75.227501206487),
新google.maps.LatLng(38.379295743902,-75.225205297693),
新的google.maps.LatLng(38.379592567387,-75.2240716986),
新的google.maps.LatLng(38.380117961665,-75.222676379481),
新的google.maps.LatLng(38.380552176823,-75.221804307849),
新google.maps.LatLng(38.38105497306,-75.221048245618),
新的google.maps.LatLng(38.381649384079,-75.220350334809),
新的google.maps.LatLng(38.382175305985,-75.219943020852),
新google.maps.LatLng(38.382792411234,-75.218983464046),
新google.maps.LatLng(38.382906436343,-75.218373032062),
新的google.maps.LatLng(38.382837460919,-75.217850047386),
新google.maps.LatLng(38.382882532651,-75.216513198939),
新的google.maps.LatLng(38.383133614228,-75.2155553914681),
新google.maps.LatLng(38.383773251117,-75.214187485867),
新的google.maps.LatLng(38.384184746827,-75.2137222033425),
新的google.maps.LatLng(38.384476969132,-75.21351853601),
新的google.maps.LatLng(38.382637564283,-75.20426480299),
新google.maps.LatLng(38.38519197244,-75.198823547699),
新google.maps.LatLng(38.405577811602,-75.19034453901),
新google.maps.LatLng(38.407028585378,-75.182599075765),
新的google.maps.LatLng(38.40722096122,-75.174076115614),
新的google.maps.LatLng(38.408363397248,-75.170436134806),
新google.maps.LatLng(38.409309204558,-75.165281800201),
新的google.maps.LatLng(38.408901468414,-75.160340258055),
新的google.maps.LatLng(38.406765903601,-75.152595654452),
新google.maps.LatLng(38.395190936758,-75.125505819646),
新的google.maps.LatLng(38.385642833873,-75.117728390668),
新google.maps.LatLng(38.374856118103,-75.119631104135),
新google.maps.LatLng(38.36627877377,-75.123365898101),
新的google.maps.LatLng(38.356385213645,-75.135886367449),
新的google.maps.LatLng(38.355748521369,-75.138697584933),
新的google.maps.LatLng(38.356588228882,-75.140827882168),
新google.maps.LatLng(38.353966142431,-75.148677720414),
新的google.maps.LatLng(38.3533999815,-75.155934132108),
新google.maps.LatLng(38.355773036555,-75.163013288465),
新的google.maps.LatLng(38.3570997232,-75.167760532105),
新的google.maps.LatLng(38.357490472371,-75.169648322129),
新的google.maps.LatLng(38.357697649263,-75.170984310809),
新的google.maps.LatLng(38.356877865946,-75.175023673389),
新的google.maps.LatLng(38.35692888534,-75.180281795915),
新的google.maps.LatLng(38.357135648358,-75.181937363443),
新google.maps.LatLng(38.357479565684,-75.182924590933),
新的google.maps.LatLng(38.358006656962,-75.184027796508),
新google.maps.LatLng(38.35789315148,-75.185131944698),
新google.maps.LatLng(38.357326389225,-75.187567228589),
新的google.maps.LatLng(38.34928043721,-75.188915754557),
新google.maps.LatLng(38.345843986823,-75.189137004871),
新google.maps.LatLng(38.345367132702,-75.190008596877),
新google.maps.LatLng(38.346404068602,-75.190624211995),
新google.maps.LatLng(38.348624653027,-75.191329323286),
新的google.maps.LatLng(38.35058254734,-75.192057763342),
新google.maps.LatLng(38.353025828197,-75.193483945018),
新的google.maps.LatLng(38.353438729258,-75.192835933727),
新google.maps.LatLng(38.355365219959,-75.192351477338),
新google.maps.LatLng(38.356135794137,-75.193697811043),
新google.maps.LatLng(38.3563850507,-75.1941453725),
新google.maps.LatLng(38.359110738339,-75.194142149659),
新google.maps.LatLng(38.3606848599,-75.19401706074),
新的google.maps.LatLng(38.36087720196,-75.197844264232),
新的google.maps.LatLng(38.364907004794,-75.197548472384),
新的google.maps.LatLng(38.36634361825,-75.200520734765),
新google.maps.LatLng(38.368920516308,-75.205852864658),
新google.maps.LatLng(38.368558991925,-75.207777168909),
新google.maps.LatLng(38.359476783305,-75.214501841143)
];
html,
身体,
#地图{
身高:100%;
宽度:100%;
边际:0px;
填充:0px;
}

完美。非常感谢。在礼节问题上-sho
google.maps.event.addListener(map, "zoom_changed", function() {
    if (map.getZoom() > 13) poly.setMap(null); 
    else poly.setMap(map);
});