帖子
帖子
用户
博客
课程
显示全部楼层
20
帖子
0
勋章
6613
Y币

baiduPanorama 模块分享

[复制链接]
发表于 2019-10-8 09:19:12
baiduPanorama
baiduPanorama 模块封装了百度全景 SDK ,为移动平台提供的一套全景图服务接口,面向广大开发者提供全景图的检索、显示和交互功能,从而更加清晰方便地展示目标位置的周边环境。百度全景 SDK 提供的所有服务是免费的,接口无次数限制。您需申请密钥(key)后,才可使用百度全景SDK。任何非营利性产品请直接使用,商业目的产品使用前请参考使用须知。 在您使用百度全景 SDK 之前,请先阅读百度地图API使用条款
文档连接  https://docs.apicloud.com/Client-API/Open-SDK/baiduPanorama

注意:
1. 使用此模块之前必须先配置 config 文件
2. 不能同时添加的模块bMap, bmLocation, baiduNavigation
ios配置
  1. <feature name="baiduPanorama">
  2.     <param name="ios_api_key" value="百度ak"" />
  3.   </feature>
复制代码
Android配置
  1. <meta-data
  2.      name="com.baidu.lbsapi.API_KEY"
  3.      value="百度ak" />
复制代码
注意 ios配置时用自己的证书的包名 如果使用的官方证书 ,请阅读  https://docs.apicloud.com/Dev-Guide/Custom_Loader 第7项。
运行截图
主要代码
  1. <!DOCTYPE html>
  2.   <html>
  3.   <head>
  4.       <meta charset="utf-8">
  5.       <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  6.       <title>title</title>
  7.       <link rel="stylesheet" type="text/css" href="../css/api.css"/>
  8.       <style>
  9.           body{

  10.           }
  11.           footer{
  12.             position: absolute;
  13.             bottom: 0;
  14.             width: 100%;
  15.             height: 200px;
  16.           }
  17.           button{
  18.             border-radius: 5px;
  19.             background-color: green;
  20.             color: #fff;
  21.             height: 30px;
  22.             margin-top: 5px;
  23.           }
  24.       </style>
  25.   </head>
  26.   <body>
  27. <footer>
  28.   <button type="button" name="button" onclick="openP()">open</button>
  29.   <button type="button" name="button" onclick="setPanoramaPitch()">setPanoramaPitch</button>
  30.   <button type="button" name="button" onclick="setPanoramaHeading()">setPanoramaHeading</button>
  31.   <button type="button" name="button" onclick="setPanoramaLevel()">setPanoramaLevel</button>
  32.   <button type="button" name="button" onclick="setShowTopoLink()">setShowTopoLink</button>
  33.   <button type="button" name="button" onclick="setPanoramaImageLevel()">setPanoramaImageLevel</button>
  34.   <button type="button" name="button" onclick="setArrowTextureByBitmap()">setArrowTextureByBitmap</button>
  35.   <button type="button" name="button" onclick="addImgMarker()">addImgMarker</button>
  36.   <button type="button" name="button" onclick="hasStreetPanoByLatLon()">hasStreetPanoByLatLon</button>
  37. </footer>
  38.   </body>
  39.   <script type="text/javascript" src="../script/api.js"></script>
  40.   <script type="text/javascript">
  41.   var baiduPanorama = '';
  42.       apiready = function(){
  43.         baiduPanorama = api.require('baiduPanorama');
  44.       };
  45.       //根据经纬度判断是否有外景
  46.       function hasStreetPanoByLatLon() {
  47.         baiduPanorama.hasStreetPanoByLatLon({
  48.                 lon: 116.384767,
  49.                 lat: 39.989539
  50.         },function(ret) {
  51.              alert(JSON.stringify(ret));
  52.         });
  53.       }
  54.       //添加标注
  55.       function addImgMarker() {
  56.         var baiduPanorama = api.require('baiduPanorama');
  57.         baiduPanorama.addImgMarker({
  58.              id: '10',
  59.              lon: 116.384766,
  60.              lat: 39.989539,
  61.             icon: 'widget://image/dropdown_anim_07.png',
  62.             height: 20.3
  63.         }, function(ret) {
  64.             alert(JSON.stringify(ret));
  65.         });
  66.       }
  67.       //设置剪头纹理
  68.       function setArrowTextureByBitmap() {
  69.         baiduPanorama.setArrowTextureByBitmap({
  70.             path: 'widget://image/dropdown_anim_08.png'
  71.         });
  72.       }
  73.       //清晰度调整
  74.       function setPanoramaImageLevel() {
  75.         var baiduPanorama = api.require('baiduPanorama');
  76.         baiduPanorama.setPanoramaImageLevel({
  77.             level: 'high'
  78.         });
  79.       }
  80.       //是否显示临街街景
  81.       function setShowTopoLink() {
  82.         baiduPanorama.setShowTopoLink({
  83.             enable: true
  84.         });
  85.       }
  86.       //设置放缩等级
  87.       function setPanoramaLevel() {
  88.         baiduPanorama.setPanoramaLevel({
  89.             level: 2
  90.         });
  91.       }
  92.       //设置偏航角
  93.       function setPanoramaHeading() {
  94.         baiduPanorama.setPanoramaHeading({
  95.             heading: 60
  96.         });
  97.       }
  98.       //调整视角
  99.       function setPanoramaPitch() {
  100.         baiduPanorama.setPanoramaPitch({
  101.             pitch: 60
  102.         });
  103.       }
  104.       //打开
  105.       function openP() {
  106.         console.log('1111');
  107.         baiduPanorama.open({
  108.             rect: {
  109.                x: 0,
  110.                y: 0,
  111.                w: api.frameWidth,
  112.                h: api.frameHeight - 200
  113.             },
  114.             fixedOn: api.frameName,
  115.             fixed: false
  116.         }, function(ret){
  117.             if( ret.status ){
  118.               console.log(ret.status);
  119.               setTimeout(function () {
  120.                 baiduPanorama.setPosition({
  121.                   lon: 116.384767,
  122.                   lat: 39.989539
  123.                 });
  124.               }, 300);
  125.             }
  126.         });
  127.       }
  128.   </script>
  129.   </html>
复制代码


本帖子中包含更多资源,您需要 登录 才可以下载或查看,没有帐号?立即注册

X
您需要登录后才可以回帖 登录

本版积分规则