function getBoundary(name) { var bdary = new BMap.Boundary(); bdary.get(name, function (rs) { //获取行政区域 var plys = []; 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); //添加覆盖物 plys.push(ply); } var pts = plys[0].getPath(); for(var i=1; i<plys.length; i++) pts = pts.concat(plys[i].getPath()); map.setViewport(pts); //调整视野 //获得边界 var zoom = map.getZoom(); varplyall = new BMap.Polygon(pts, { strokeWeight: 2, strokeColor: "#ff0000" }); //建立多边形覆盖物 var swBounds = varplyall.getBounds().getSouthWest(); var neBounds = varplyall.getBounds().getNorthEast(); //平面坐标 var projection =map.getMapType().getProjection(); var swPt = projection.lngLatToPoint(swBounds); var nePt = projection.lngLatToPoint(neBounds); window.external.MapInfo2App(zoom, swPt.x, swPt.y, nePt.x, nePt.y); }); }