首页 > 代码库 > [Baidu Map]添加全景地图

[Baidu Map]添加全景地图

关键代码:

/*为地图添加全景@map BMap.Map@divid 全景地图承载div@ylng,xlat 全景地图初始化经纬度eg:panorama = addPanorama(map, ‘panorama‘, ylng, xlat);*/function addPanorama(map, divid, ylng, xlat) {    var panorama = new BMap.Panorama(divid); //全景图展示    panorama.setPosition(new BMap.Point(ylng, xlat)); //根据经纬度坐标展示全景图    panorama.setPov({ heading: -40, pitch: 6 });    return panorama;}/*为地图添加全景控件@map BMap.Mapeg:addPanoramaControl(map);*/function addPanoramaControl(map) {    var panoramaCtrl = new BMap.PanoramaControl(); //构造全景控件    panoramaCtrl.setOffset(new BMap.Size(20, 20));    map.addControl(panoramaCtrl); //添加全景控件    map.addTileLayer(new BMap.PanoramaCoverageLayer());}

<style type="text/css">.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }</style>

代码适用于:API 2.0

参考:全景类参考