|
[问题求助]
Bmap 里面的addAnnotations 这个方法怎么用的
[复制链接]
求助百度地图的标注功能怎么用的,我用了open可以打开,但是用标注大头针的功能就不行了,求解。
文档说明:https://docs.apicloud.com/Client-API/Open-SDK/bMap#addAnnotations
我的代码如下:
- <template>
- <view class="page">
- </view>
- </template>
- <script>
- export default {
- name: 'map',
- apiready() {//like created
- this.data.map = api.require('bMap');
- this.data.map.setAgreePrivacy({
- agree: true
- });
- this.data.map.initMapSDK((ret) => {
- if (ret.status) {
- this.openMap();
- }
- });
- },
- data() {
- return {
- map: null
- }
- },
- methods: {
- openMap() {
- this.data.map.open({
- rect: {
- x: 0,
- y: 0,
- w: api.winWidth,
- h: api.winHeight
- },
- center: {
- lon: 116.4021310000,
- lat: 39.9994480000
- },
- zoomLevel: 14,
- showUserLocation: true,
- fixedOn: api.frameName,
- fixed: true
- }, (ret) => {
- if (ret.status) {
- console.log('地图打开成功');
- this.data.map.addAnnotations({
- annotations: [{
- id: 1,
- lon: 116.297,
- lat: 40.109
- }, {
- id: 2,
- lon: 116.29,
- lat: 40.109
- }, {
- id: 3,
- lon: 116.298,
- lat: 40.11
- }],
- icon: 'widget://',
- draggable: true
- }, function (ret) {
- console.log(JSON.stringify(ret))
- });
- }
- });
- }
- }
- }
- </script>
- <style>
- .page {
- height: 100%;
- }
- </style>
复制代码
|
|