百度地圖JavaScript API開發疊加行政區劃圖,javascriptapi

來源:互聯網
上載者:User

百度地圖JavaScript API開發疊加行政區劃圖,javascriptapi

疊加顯示上海:

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}#l-map{height:100%;width:78%;float:left;border-right:2px solid #bcbcbc;}#r-result{height:100%;width:20%;float:left;}</style><script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=0Ea24345073256b9232eddc3e8284aca"></script><title>疊加行政區劃圖</title></head><body><div id="allmap"></div></body></html><script type="text/javascript">var map = new BMap.Map("allmap");map.centerAndZoom(new BMap.Point(116.403765, 39.914850), 7);map.enableScrollWheelZoom();function getBoundary(){           var bdary = new BMap.Boundary();    bdary.get("上海", function(rs){       //擷取行政地區        map.clearOverlays();        //清除地圖覆蓋物               var count = rs.boundaries.length; //行政地區的點有多少個        for(var i = 0; i < count; i++){            var ply = new BMap.Polygon(rs.boundaries[i], {strokeWeight: 2, strokeColor: "#ff0000"}); //建立多邊形覆蓋物            map.addOverlay(ply);  //添加覆蓋物            map.setViewport(ply.getPath());    //調整視野                 }                    });   }function getBoundary2(){           var bdary = new BMap.Boundary();    bdary.get("武漢", function(rs){       //擷取行政地區        map.clearOverlays();        //清除地圖覆蓋物               var count = rs.boundaries.length; //行政地區的點有多少個        for(var i = 0; i < count; i++){            var ply = new BMap.Polygon(rs.boundaries[i], {strokeWeight: 2, strokeColor: "red"}); //建立多邊形覆蓋物            map.addOverlay(ply);  //添加覆蓋物            map.setViewport(ply.getPath());    //調整視野                 }                    });   }setTimeout(function(){    getBoundary();    getBoundary2();}, 1500);</script>

希望以上分享對各位朋友有些協助,謝謝!
更多關注付義方技術部落格:http://blog.csdn.net/fuyifang
或者直接用手機掃描二維碼查看更多博文:

著作權聲明:本文為博主原創文章,未經博主允許不得轉載, 更多關注付義方技術部落格:http://blog.csdn.net/fuyifang

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.