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

[问题求助] Bmap 里面的addAnnotations 这个方法怎么用的

[复制链接]
发表于 2022-9-20 21:47:08
求助百度地图的标注功能怎么用的,我用了open可以打开,但是用标注大头针的功能就不行了,求解。

文档说明:https://docs.apicloud.com/Client-API/Open-SDK/bMap#addAnnotations

我的代码如下:
  1. <template>
  2.         <view class="page">

  3.         </view>
  4. </template>
  5. <script>
  6. export default {
  7.         name: 'map',
  8.         apiready() {//like created
  9.                 this.data.map = api.require('bMap');

  10.                 this.data.map.setAgreePrivacy({
  11.                         agree: true
  12.                 });

  13.                 this.data.map.initMapSDK((ret) => {
  14.                         if (ret.status) {

  15.                                 this.openMap();
  16.                         }
  17.                 });

  18.         },
  19.         data() {
  20.                 return {
  21.                         map: null
  22.                 }
  23.         },
  24.         methods: {
  25.                 openMap() {
  26.                         this.data.map.open({
  27.                                 rect: {
  28.                                         x: 0,
  29.                                         y: 0,
  30.                                         w: api.winWidth,
  31.                                         h: api.winHeight
  32.                                 },
  33.                                 center: {
  34.                                         lon: 116.4021310000,
  35.                                         lat: 39.9994480000
  36.                                 },
  37.                                 zoomLevel: 14,
  38.                                 showUserLocation: true,
  39.                                 fixedOn: api.frameName,
  40.                                 fixed: true
  41.                         }, (ret) => {
  42.                                 if (ret.status) {
  43.                                         console.log('地图打开成功');
  44.                                         this.data.map.addAnnotations({
  45.                                                 annotations: [{
  46.                                                         id: 1,
  47.                                                         lon: 116.297,
  48.                                                         lat: 40.109
  49.                                                 }, {
  50.                                                         id: 2,
  51.                                                         lon: 116.29,
  52.                                                         lat: 40.109
  53.                                                 }, {
  54.                                                         id: 3,
  55.                                                         lon: 116.298,
  56.                                                         lat: 40.11
  57.                                                 }],
  58.                                                 icon: 'widget://',
  59.                                                 draggable: true
  60.                                         }, function (ret) {
  61.                                                 console.log(JSON.stringify(ret))
  62.                                         });
  63.                                 }
  64.                         });
  65.                 }
  66.         }
  67. }
  68. </script>
  69. <style>
  70. .page {
  71.         height: 100%;
  72. }
  73. </style>
复制代码




380
帖子
4
勋章
6
Y币
  icon: 'widget://',   图片传完整
45
帖子
0
勋章
132
Y币
技术咨询-F · 2022-9-21 09:44icon: 'widget://',   图片传完整

好的,感谢,可以了
黄枰凯 · 2022-9-21 22:00好的,感谢,可以了

好的
您需要登录后才可以回帖 登录

本版积分规则