代码
var panorama = new BMap.Panorama('map');
panorama.setPosition(new BMap.Point(120.31, 31.58));
var panoramaService = new BMap.PanoramaService();
panoramaService.getPanoramaByLocation(new BMap.Point(120.31, 31.58), function (data) {
var panoramaInfo = '';
if (data == null) {
console.log('no data');
return;
}
panoramaInfo += '全景id为:' + data.id + '\n';
panoramaInfo += '<br/>全景路段名为:' + data.description + '\n';
panoramaInfo += '<br/>坐标为:' + data.position.lng + ':' + data.position.lat + '\n';
document.getElementById('text').innerHTML = panoramaInfo;
});
通过 BMap.PanoramaService 来获取全景图数据
预览