我在使用谷歌的infoBox扩展时发现了一些奇怪的东西。当显示infoBox时,可以单击infoBox下方的标记,即使它们不可见。在我的情况下,我猜在大多数情况下这是非常不受欢迎的。如何将infoBox'置于顶部',以便infoBox下方的标记无法点击。
下面是一些小代码片段。单击顶部标记。将鼠标移到infoBox的其他标记所在的空白处。光标变为指针,标记可点击。 BTW谷歌自己的符号也可点击。这也是不可取的。
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('6 7(a){a=a||{};B.C.1E.1Z(2,2C);2.17=a.1m||"";2.1j=a.1h||16;2.14=a.1x||0;2.L=a.1q||11 B.C.1I(0,0);2.K=a.W||11 B.C.1H(0,0);2.T=a.U||F;2.1z=a.1y||{};2.1e=a.1g||"2S";2.R=a.1b||"2F://2B.B.2z/2v/2t/2q/1r.2l";4(a.1b===""){2.R=""}2.1a=a.1k||11 B.C.1I(1,1);2.V=a.1i||16;2.1F=a.25||"23";2.3=F;2.G=F;2.N=F}7.8=11 B.C.1E();7.8.1C=6(){5 a;4(!2.3){2.3=18.1Y("1X");2.1d();2.3.9.W="1W";2.3.9.S=\'1w\';4(2.T!==F){2.3.9.U=2.T}2.3.1v=2.1c()+2.17;2.2O()[2.1F].2H(2.3);2.1u();4(2.3.9.J){2.N=1t}Y{4(2.14!==0&&2.3.13>2.14){2.3.9.J=2.14;2.3.9.2w="2u";2.N=1t}Y{a=2.1M();2.3.9.J=(2.3.13-a.X-a.12)+"15";2.N=16}}2.1o(2.1j);B.C.H.Z(2,"2k")}};7.8.1c=6(){5 a="";4(2.R!==""){a="<2j";a+=" 2i=\'"+2.R+"\'";a+=" 2g=12";a+=" 9=\'";a+=" W: 2f;";a+=" 2c: 2b;";a+=" 2a: "+2.1e+";";a+="\'>"}Q a};7.8.1u=6(){5 a;4(2.R!==""){a=2.3.29;2.G=B.C.H.28(a,\'27\',2.1G())}Y{2.G=F}};7.8.1G=6(){5 a=2;Q 6(){a.1r();B.C.H.Z(a,"26")}};7.8.1o=6(A){4(!A){5 d=2.24();5 v=d.22();5 i=d.21();5 g=i.13;5 j=i.1D;5 b=v.20();5 h=b.M();5 r=b.O();5 o=h/g;5 s=r/j;5 t=v.1B().M();5 m=v.1A().M();5 e=v.1A().O();5 y=v.1B().O();5 a=2.K;5 u=2.L.J;5 w=2.L.1f;5 n=2.1a.J;5 p=2.1a.1f;5 z=a.M()+(u-n)*o;5 x=a.M()+(u+2.3.13+n)*o;5 k=a.O()-(w-p)*s;5 q=a.O()-(w+2.3.1D+p)*s;5 l=(z<t?t-z:0)+(x>m?m-x:0);5 f=(k>e?e-k:0)+(q<y?y-q:0);4(!(f===0&&l===0)){5 c=d.2R();d.2P(11 B.C.1H(c.O()-f,c.M()-l))}}};7.8.1d=6(){5 i;5 a=2.1z;2M(i 2K a){4(a.2G(i)){2.3.9[i]=a[i]}}4(E 2.3.9.1l!=="D"){2.3.9.2E="2D(1l="+(2.3.9.1l*2A)+")"}};7.8.1M=6(){5 c;5 a={19:0,1s:0,X:0,12:0};5 b=2.3;4(18.1n&&18.1n.1P){c=b.2y.1n.1P(b,"");4(c){a.19=I(c.1O,10)||0;a.1s=I(c.1N,10)||0;a.X=I(c.1L,10)||0;a.12=I(c.1Q,10)||0}}Y 4(18.2s.P){4(b.P){a.19=I(b.P.1O,10)||0;a.1s=I(b.P.1N,10)||0;a.X=I(b.P.1L,10)||0;a.12=I(b.P.1Q,10)||0}}Q a};7.8.2r=6(){4(2.3){2.3.2x.2p(2.3);2.3=F}};7.8.1p=6(){2.1C();5 a=2.2o().2n(2.K);2.3.9.X=(a.x+2.L.J)+"15";2.3.9.19=(a.y+2.L.1f)+"15";4(2.V){2.3.9.S=\'1w\'}Y{2.3.9.S="1K"}};7.8.2m=6(a){4(E a.1y!=="D"){2.1z=a.1y;2.1d()}4(E a.1m!=="D"){2.1J(a.1m)}4(E a.1h!=="D"){2.1j=a.1h}4(E a.1x!=="D"){2.14=a.1x}4(E a.1q!=="D"){2.L=a.1q}4(E a.W!=="D"){2.1V(a.W)}4(E a.U!=="D"){2.1U(a.U)}4(E a.1g!=="D"){2.1e=a.1g}4(E a.1b!=="D"){2.R=a.1b}4(E a.1k!=="D"){2.1a=a.1k}4(E a.1i!=="D"){2.V=a.1i}4(2.3){2.1p()}};7.8.1J=6(a){2.17=a;4(2.3){4(2.G){B.C.H.1S(2.G);2.G=F}4(!2.N){2.3.9.J=""}2.3.1v=2.1c()+a;4(!2.N){2.3.9.J=2.3.13+"15";2.3.1v=2.1c()+a}2.1u()}B.C.H.Z(2,"2I")};7.8.1V=6(a){2.K=a;4(2.3){2.1p()}B.C.H.Z(2,"2J")};7.8.1U=6(a){2.T=a;4(2.3){2.3.9.U=a}B.C.H.Z(2,"2h")};7.8.2L=6(){Q 2.17};7.8.1R=6(){Q 2.K};7.8.2N=6(){Q 2.T};7.8.2e=6(){2.V=16;2.3.9.S="1K"};7.8.2d=6(){2.V=1t;2.3.9.S="1w"};7.8.2Q=6(b,a){4(a){2.K=a.1R()}2.1T(b);4(2.3){2.1o()}};7.8.1r=6(){4(2.G){B.C.H.1S(2.G);2.G=F}2.1T(F)};',62,179,'||this|div_|if|var|function|InfoBox|prototype|style||||||||||||||||||||||||||||google|maps|undefined|typeof|null|closeListener_|event|parseInt|width|position_|pixelOffset_|lng|fixedWidthSet_|lat|currentStyle|return|closeBoxURL_|visibility|zIndex_|zIndex|isHidden_|position|left|else|trigger||new|right|offsetWidth|maxWidth_|px|false|content_|document|top|infoBoxClearance_|closeBoxURL|getCloseBoxImg_|setBoxStyle_|closeBoxMargin_|height|closeBoxMargin|disableAutoPan|isHidden|disableAutoPan_|infoBoxClearance|opacity|content|defaultView|panBox_|draw|pixelOffset|close|bottom|true|addClickHandler_|innerHTML|hidden|maxWidth|boxStyle|boxStyle_|getNorthEast|getSouthWest|createInfoBoxDiv_|offsetHeight|OverlayView|pane_|getCloseClickHandler_|LatLng|Size|setContent|visible|borderLeftWidth|getBoxWidths_|borderBottomWidth|borderTopWidth|getComputedStyle|borderRightWidth|getPosition|removeListener|setMap|setZIndex|setPosition|absolute|div|createElement|apply|toSpan|getDiv|getBounds|floatPane|getMap|pane|closeclick|click|addDomListener|firstChild|margin|pointer|cursor|hide|show|relative|align|zindex_changed|src|img|domready|gif|setOptions|fromLatLngToDivPixel|getProjection|removeChild|mapfiles|onRemove|documentElement|en_us|auto|intl|overflow|parentNode|ownerDocument|com|100|www|arguments|alpha|filter|http|hasOwnProperty|appendChild|content_changed|position_changed|in|getContent|for|getZIndex|getPanes|setCenter|open|getCenter|2px'.split('|'),0,{}))
var myOptions = {
content: "aa"
,disableAutoPan: true
,maxWidth: 0
,pixelOffset: new google.maps.Size(-140, -5)
,zIndex: null
,boxStyle: {
backgroundColor:"white",
width: "280px",
height:"110px",
overflow:"hidden",
zIndex:"99999",
borderRadius:"2px",
boxSizing:"border-box",
MozBoxSizing:"border-box",
webkitBoxSizing:"border-box",
padding:"5px",
border:"1px solid #708187",
font:"12px verdana",
lineHeight:"20px"
}
,closeBoxMargin: "2px 2px 2px 2px"
,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
,infoBoxClearance: new google.maps.Size(5, 1)
,isHidden: false
,pane: "floatPane"
,enableEventPropagation: false
};
var ibb = new InfoBox(myOptions);
ibb.isClicked = false;
ibb.isOpen = false;
var LocationData = [
[49.2818668, -123.1025187, "Top Marker. If this marker is clicked other markers <b>should not be clickable</b> but they are." ],
[49.2812668, -123.1035942, "Marker" ],
[49.2812336, -123.1020622, "Marker" ],
[49.2813564, -123.1012253, "Marker" ]
];
function initialize()
{
var mapOptions = {disableDefaultUI: true}
var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
var bounds = new google.maps.LatLngBounds();
var infowindow = new google.maps.InfoWindow();
for (var i in LocationData)
{
var p = LocationData[i];
var latlng = new google.maps.LatLng(p[0], p[1]);
bounds.extend(latlng);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: p[2]
});
google.maps.event.addListener(marker, 'click', (function(mm, tt) {
return function() {
ibb.setContent(tt);
ibb.open(map, mm);
ibb.isOpen = true;
}
})(marker, p[2]));
}
map.fitBounds(bounds);
}
google.maps.event.addDomListener(window, 'load', initialize);
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<div id="map-canvas" style="width:500px;height:500px;"></div>
答案 0 :(得分:0)
一种解决方案可能是改变你的infowindow的latlong位置,以确保它不会与标记重叠。