百度地图 聚合(MarkerClusterer )

前端之家收集整理的这篇文章主要介绍了百度地图 聚合(MarkerClusterer )前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE>
<html>
  <head>
    <Meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>MarkerClusterer for Baidu Map Example</title>

    <style type="text/css">
        #mapDiv1 { height:400px; width:600px; margin:20px }
		#mapDiv2 { height:400px; width:600px; margin:20px; left:620px; top:-420px;}
    </style>

    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.1&services=true"></script>	
    <script type="text/javascript" src="markerclusterer.js"></script>

 </head>
  <body>
    <div id="mapDiv1"></div>
	<div id="mapDiv2"></div>
    <div style="clear:both">
        <script type="text/javascript"><!--
        google_ad_client = "ca-pub-5845154460812025";
        /* 横幅728*90 */
        google_ad_slot = "8606107205";
        google_ad_width = 728;
        google_ad_height = 90;
        //-->
        </script>
        <script type="text/javascript" src="show_ads.js">
        </script>
    </div>
    <script type="text/javascript">
        var map = new BMap.Map("mapDiv1");            
        map.enableScrollWheelZoom();
        var point = new BMap.Point(116.404,39.915);   
        map.centerAndZoom(point,4);   
        
        var map2 = new BMap.Map("mapDiv2");            
        map2.enableScrollWheelZoom();
        map2.centerAndZoom(point,4); 
     
         map.addEventListener("zoomend",function(){
            map2.zoomTo(map.getZoom());
            map2.panTo(map.getCenter());
        });

        map.addEventListener("moveend",function(){
            map2.panTo(map.getCenter());
        });
        
 
     
        var markers = [];
        var pt = null;
        var marker = null;
        for (var i = 0; i < 100; i++) {
            pt = new BMap.Point(Math.random()*40+85,Math.random()*30+21);
            marker = new BMap.Marker(pt);
            markers.push(marker);
            
            var mk2 = new BMap.Marker(pt);
            map2.addOverlay(mk2);
        }
        var markerClusterer = new MarkerClusterer(map,markers);
           
    </script>
  </body>
</html>


引用show_ads.js

(function(){var g=null,h=(new Date).getTime();var i=this,aa=function(a,b){var c=a.split("."),d=i;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&b!==void 0?d[e]=b:d=d[e]?d[e]:d[e]={}},ba=function(a,b,c){return a.call.apply(a.bind,arguments)},ca=function(a,c){var d=b||i;if(arguments.length>2){var e=Array.prototype.slice.call(arguments,2);return function(){var b=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(b,e);return a.apply(d,b)}}else return function(){return a.apply(d,arguments)}},j=function(a,c){j=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?ba:ca;return j.apply(g,arguments)};var ea=/&/g,fa=/</g,ga=/>/g,ha=/\"/g,k={"\0":"\\0","\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\u000b":"\\x0B",'"':'\\"',"\\":"\\\\"},n={"'":"\\'"},q=function(a,b){if(a<b)return-1;else if(a>b)return 1;return 0};var s,v,w,y,ia=function(){return i.navigator?i.navigator.userAgent:g};y=w=v=s=!1;var z;if(z=ia()){var ja=i.navigator;s=z.indexOf("Opera")==0;v=!s&&z.indexOf("MSIE")!=-1;w=!s&&z.indexOf("WebKit")!=-1;y=!s&&!w&&ja.product=="Gecko"}var A=v,C=y,ka=w,D;
a:{var E="",F;if(s&&i.opera)var G=i.opera.version,E=typeof G=="function"?G():G;else if(C?F=/rv\:([^\);]+)(\)|;)/:A?F=/MSIE\s+([^\);]+)(\)|;)/:ka&&(F=/WebKit\/(\S+)/),F)var la=F.exec(ia()),E=la?la[1]:"";if(A){var H,ma=i.document;H=ma?ma.documentMode:void 0;if(H>parseFloat(E)){D=String(H);break a}}D=E}
var na=D,oa={},I=function(a){var b;if(!(b=oa[a])){b=0;for(var c=String(na).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,e=Math.max(c.length,d.length),f=0;b==0&&f<e;f++){var sa=c[f]||"",r=d[f]||"",l=RegExp("(\\d*)(\\D*)","g"),x=RegExp("(\\d*)(\\D*)","g");do{var o=l.exec(sa)||["","",""],m=x.exec(r)||["",""];if(o[0].length==0&&m[0].length==0)break;b=q(o[1].length==0?0:parseInt(o[1],10),m[1].length==0?0:parseInt(m[1],10))||q(o[2].length==
0,m[2].length==0)||q(o[2],m[2])}while(b==0)}b=oa[a]=b>=0}return b};var pa=document,J=window;var K=function(a){a=parseFloat(a);return isNaN(a)||a>1||a<0?0:a},L=function(a){return a=="true"?!0:a=="false"?!1:!1},qa=/^([\w-]+\.)*([\w-]{2,})(\:[0-9]+)?$/,M=function(a){return!a?"pagead2.googlesyndication.com":(a=a.match(qa))?a[0]:"pagead2.googlesyndication.com"};var ra=K("0"),ta=K("0"),ua=K("0.2"),va=K("0.02");var wa=L("false"),xa=L("false"),ya=L("false");var za=function(){return M("")};!A||I("9");!C&&!A||A&&I("9")||C&&I("1.9.1");A&&I("9");M("");var N=function(a){return!!a&&typeof a=="function"&&!!a.call},Aa=function(a,b){if(!(arguments.length<2))for(var c=1,d=arguments.length;c<d;++c)a.push(arguments[c])};function O(a){return typeof encodeURIComponent=="function"?encodeURIComponent(a):escape(a)}function Ba(a,b){a.attachEvent?a.attachEvent("onload",b):a.addEventListener&&a.addEventListener("load",!1)}
function Ca(a,b){if(!(Math.random()<1.0E-4)){var c=Math.random();if(c<b)return a[Math.floor(c/b*a.length)]}return""};aa("google_protectAndRun",function(a,c){a=j(b,i,a);b=window.onerror;window.onerror=a;try{c()}catch(d){var c=d.toString(),e="";d.fileName&&(e=d.fileName);var f=-1;if(d.lineNumber)f=d.lineNumber;if(!a(c,e,f))throw d;}window.onerror=b});
aa("google_handleError",c,d){if(Math.random()<0.01)a=["http://",za(),"/pagead/gen_204","?id=jserror","&jscb=",wa?1:0,"&jscd=",xa?1:0,"&context=",O(a),"&msg=",O(b),"&file=",O(c),"&line=",O(d.toString()),"&url=",O(pa.URL.substring(0,512)),"&ref=",O(pa.referrer.substring(0,512))],a.push(["&client=",O(J.google_ad_client),"&format=",O(J.google_ad_format),"&slotname=",O(J.google_ad_slot),"&output=",O(J.google_ad_output),"&ad_type=",O(J.google_ad_type)].join("")),a=a.join(""),J.google_image_requests||
(J.google_image_requests=[]),b=new Image,b.src=a,J.google_image_requests.push(b);return!ya});var Da=function(a){try{var b=a.google_test;a.google_test=!b;if(a.google_test===!b)return a.google_test=b,!0}catch(c){}return!1},P=g,Ea=function(){if(!P){for(var a=window;a!=a.parent&&Da(a.parent);)a=a.parent;P=a}return P};var Q,R=function(a){this.c=[];this.a=a||window;this.b=0;this.d=g},Ga=function(a,b){this.l=a;this.i=b};R.prototype.n=function(a,b){this.b==0&&this.c.length==0&&(!b||b==window)?(this.b=2,this.g(new Ga(a,window))):this.h(a,b)};R.prototype.h=function(a,b){this.c.push(new Ga(a,b||this.a));S(this)};R.prototype.o=function(a){this.b=1;if(a)this.d=this.a.setTimeout(j(this.f,this),a)};R.prototype.f=function(){if(this.b==1){if(this.d!=g)this.a.clearTimeout(this.d),this.d=g;this.b=0}S(this)};R.prototype.p=function(){return!0};
R.prototype.nq=R.prototype.n;R.prototype.nqa=R.prototype.h;R.prototype.al=R.prototype.o;R.prototype.rl=R.prototype.f;R.prototype.sz=R.prototype.p;var S=function(a){a.a.setTimeout(j(a.m,a),0)};R.prototype.m=function(){if(this.b==0&&this.c.length){var a=this.c.shift();this.b=2;a.i.setTimeout(j(this.g,this,0);S(this)}};R.prototype.g=function(a){this.b=0;a.l()};
var Ha=function(a){try{return a.sz()}catch(b){return!1}},Ia=function(a){return!!a&&(typeof a=="object"||typeof a=="function")&&Ha(a)&&N(a.nq)&&N(a.nqa)&&N(a.al)&&N(a.rl)},Ja=function(){if(Q&&Ha(Q))return Q;var a=Ea(),b=a.google_jobrunner;return Ia(b)?Q=b:a.google_jobrunner=Q=new R(a)},Ka=function(a,b){Ja().nq(a,b)},La=function(a,b){Ja().nqa(a,b)};var Ma=/Chrome|Firefox|MSIE 8/,Na=/MSIE [2-7]|PlayStation/i,Oa=/Android|Opera|Web Preview/,Pa=function(){var a=T,b=U.google_ad_width,c=U.google_ad_height,d=["<iframe"],e;for(e in a)a.hasOwnProperty(e)&&Aa(d,e+"="+a[e]);d.push('style="left:0;position:absolute;top:0;"');d.push("></iframe>");b="border:none;height:"+c+"px;margin:0;padding:0;position:relative;visibility:visible;width:"+b+"px";return['<ins style="display:inline-table;','"><ins id="',a.id+"_anchor",'" style="display:block;','">',d.join(" "),"</ins></ins>"].join("")};var Qa=function(){},Sa=function(a,c){switch(typeof b){case "string":Ra(b,c);break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(b==g){c.push("null");break}if(b instanceof Array){var d=b.length;c.push("[");for(var e="",f=0;f<d;f++)c.push(e),Sa(a,b[f],c),e=",";c.push("]");break}c.push("{");d="";for(e in b)b.hasOwnProperty(e)&&(f=b[e],typeof f!="function"&&(c.push(d),Ra(e,c.push(":"),f,d=
","));c.push("}");break;case "function":break;default:throw Error("Unknown type: "+typeof b);}},Ta={'"':'\\"',"\\":"\\\\","/":"\\/","\u000b":"\\u000b"},Ua=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g,Ra=function(a,b){b.push('"');b.push(a.replace(Ua,function(a){if(a in Ta)return Ta[a];var b=a.charCodeAt(0),e="\\u";b<16?e+="000":b<256?e+="00":b<4096&&(e+="0");return Ta[a]=e+b.toString(16)}));b.push('"')};var V=["google_ad_block","google_ad_channel","google_ad_client","google_ad_format","google_ad_height","google_ad_host","google_ad_host_channel","google_ad_host_tier_id","google_ad_output","google_ad_override","google_ad_region","google_ad_section","google_ad_slot","google_ad_type","google_ad_width","google_adtest","google_allow_expandable_ads","google_alternate_ad_url","google_alternate_color","google_analytics_domain_name","google_analytics_uacct","google_bid","google_city","google_color_bg","google_color_border","google_color_line","google_color_link","google_color_text","google_color_url","google_container_id","google_contents","google_country","google_cpm","google_ctr_threshold","google_cust_age","google_cust_ch","google_cust_gender","google_cust_id","google_cust_interests","google_cust_job","google_cust_l","google_cust_lh","google_cust_u_url","google_disable_video_autoplay","google_ed","google_eids","google_enable_osd","google_encoding","google_font_face","google_font_size","google_frame_id","google_gl","google_hints","google_image_size","google_kw","google_kw_type","google_language","google_max_num_ads","google_max_radlink_len","google_num_radlinks","google_num_radlinks_per_unit","google_num_slots_to_rotate","google_only_ads_with_video","google_only_pyv_ads","google_only_userchoice_ads","google_override_format","google_page_url","google_referrer_url","google_region","google_reuse_colors","google_rl_dest_url","google_rl_filtering","google_rl_mode","google_rt","google_safe","google_skip","google_tag_info","google_targeting","google_ui_features","google_ui_version","google_video_doc_id","google_video_product_type","google_with_pyv_ads"];var W=function(a){this.a=a;a.google_iframe_oncopy||(a.google_iframe_oncopy={handlers:{},log:[],img:Math.random()<0.01?[]:g});this.e=a.google_iframe_oncopy;a.setTimeout(j(this.k,3E4)},Va;var X="var i=this.id,s=window.google_iframe_oncopy,H=s&&s.handlers,h=H&&H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&&d&&(!d.body||!d.body.firstChild)){if(h.call){i+='.call';setTimeout(h,0)}else if(h.match){i+='.nav';w.location.replace(h)}s.log&&s.log.push(i)}";
/[&<>\"]/.test(X)&&(X.indexOf("&")!=-1&&(X=X.replace(ea,"&")),X.indexOf("<")!=-1&&(X=X.replace(fa,"<")),X.indexOf(">")!=-1&&(X=X.replace(ga,">")),X.indexOf('"')!=-1&&(X=X.replace(ha,""")));Va=X;W.prototype.set=function(a,b){this.e.handlers[a]=b;this.a.addEventListener&&this.a.addEventListener("load",j(this.j,!1)};W.prototype.j=function(a){var a=this.a.document.getElementById(a),b=a.contentWindow.document;if(a.onload&&b&&(!b.body||!b.body.firstChild))a.onload()};
W.prototype.k=function(){if(this.e.img){var a=this.e.log,b=this.a.document;if(a.length)b=["http://","/pagead/gen_204?id=iframecopy&log=",O(a.join("-")),O(b.URL.substring(0,O(b.referrer.substring(0,512))].join(""),a.length=0,a=new Image,this.e.img.push(a),a.src=b}};var Wa=function(){var a="script";return["<",a,' src="http://',M(""),'/pagead/js/r20110608/r20110616/show_ads_impl.js"></',">"].join("")},Xa=function(a,d){return function(){var e=!1;d&&Ja().al(3E4);try{var f;try{f=!!a.document.getElementById(b).contentWindow.document}catch(sa){f=!1}if(f){var r=a.document.getElementById(b).contentWindow,l=r.document;if(!l.body||!l.body.firstChild)l.open(),r.google_async_iframe_close=!0,l.write(c)}else{var x=a.document.getElementById(b).contentWindow,o;f=c;f=String(f);if(f.quote)o=f.quote();else{r=['"'];for(l=0;l<f.length;l++){var m=f.charAt(l),Fa=m.charCodeAt(0),ob=r,pb=l+1,da;if(!(da=k[m])){var B;if(Fa>31&&Fa<127)B=m;else{var p=m;if(p in n)B=n[p];else if(p in k)B=n[p]=k[p];else{var t=p,u=p.charCodeAt(0);if(u>31&&u<127)t=p;else{if(u<256){if(t="\\x",u<16||u>256)t+="0"}else t="\\u",u<4096&&(t+="0");
t+=u.toString(16).toUpperCase()}B=n[p]=t}}da=B}ob[pb]=da}r.push('"');o=r.join("")}x.location.replace("javascript:"+o)}e=!0}catch(vb){x=Ea().google_jobrunner,Ia(x)&&x.rl()}e&&(new W(a)).set(b,Xa(a,!1))}},Ya=function(){return ra&&ta/ra||typeof window.google_hash_ratio=="number"&&window.google_hash_ratio||g};window.google_loader_used=!0;(function(a){if(!("google_onload_fired"in a))a.google_onload_fired=!1,Ba(a,function(){a.google_onload_fired=!0})})(window);if(!window.google_loader_experiment)window.google_loader_experiment=Ca(["async_good_black","block_good_black"],ua)||Ca(["async_bad_black","block_bad_black"],va)||"launch";var Za;a:{try{if(window.google_enable_async!==!0&&window.google_loader_experiment=="blockodd"&&window.top.location.hostname.length%2==1){Za=!1;break a}}catch($a){}Za=!0}var ab;
if(ab=Za){var bb;if(window.google_enable_async===!1)bb=0;else{var cb=navigator.userAgent,db=window.google_loader_experiment;bb=(Na.test(cb)?!1:Oa.test(cb)?db=="async_bad_black":Ma.test(cb)?!0:db=="async_good_black")&&!window.google_container_id&&(!window.google_ad_output||window.google_ad_output=="html")}ab=bb}
if(ab){var eb=window;eb.google_unique_id?++eb.google_unique_id:eb.google_unique_id=1;for(var Y=window,_script$inline_180="script",Z,U=Y,T={allowtransparency:'"true"',frameborder:'"0"',height:'"'+Y.google_ad_height+'"',hspace:'"0"',marginwidth:'"0"',marginheight:'"0"',onload:'"'+Va+'"',scrolling:'"no"',vspace:'"0"',width:'"'+Y.google_ad_width+'"'},fb=U.document,$=T.id,gb=0;!$||U.document.getElementById($);)$="aswift_"+gb++;T.id=$;T.name=$;fb.write(Pa());Z=$;var hb;Y.google_page_url&&(Y.google_page_url=
String(Y.google_page_url));for(var ib=[],jb=0,kb=V.length;jb<kb;jb++){var lb=V[jb];if(Y[lb]!=g){var mb;try{var nb=[];Sa(new Qa,Y[lb],nb);mb=nb.join("")}catch(qb){}mb&&Aa(ib,lb,"=",mb,";")}}hb=ib.join("");for(var rb=0,sb=V.length;rb<sb;rb++)Y[V[rb]]=g;var tb=(new Date).getTime(),ub=Ya(),wb=window.google_loader_experiment,xb=["<!doctype html><html><body><",_script$inline_180,">",hb,"google_show_ads_impl=true;google_unique_id=",Y.google_unique_id,';google_async_iframe_id="','";google_start_time=',h,";",ub?"google_hash_ratio="+ub+";":"",wb?'google_loader_experiment="'+wb+'";':"","google_bpp=",tb>h?tb-h:1,";</",Wa(),"</body></html>"].join("");(Y.document.getElementById(Z)?Ka:La)(Xa(Y,xb,!0))}else window.google_start_time=h,window.google_hash_ratio=Ya(),document.write(Wa());})();


以上参照百度地图API
原文链接:https://www.f2er.com/javaschema/287192.html

猜你在找的设计模式相关文章