微信小程序地图

在地图上定位用户的位置

 wx.getLocation({ //获取当前经纬度
            type: 'gcj02',
            altitude: true, //高精度定位
            //定位成功,更新定位结果
            success: res => {
                console.log(res);
                console.log(this);
                this.longitude = res.longitude;
                this.latitude = res.latitude;
                this.speed = res.speed;
                this.accuracy = res.accuracy;
                this.$apply();
            },
            //定位失败回调
            fail: function() {
                wx.showToast({
                    title: '定位失败',
                    icon: 'none'
                });
            },

            complete: function() {
                //隐藏定位中信息进度
                wx.hideLoading();
            }
        });

在地图上标识商家所有店铺的位置

 <map
            id="map"
            longitude="{{longitude}}"
            latitude="{{latitude}}"
            markers="{{markers}}"    //标识位置
            include-points="{{markers}}"
            covers="{{covers}}"
            show-location
            bindmarkertap="showModal"     //点击标识出现弹窗
            style="width: 100%; height: 300px;"
            bindtap="hiddenmodal"
          >
发布了10 篇原创文章 · 获赞 1 · 访问量 300

猜你喜欢

转载自blog.csdn.net/weixin_45308258/article/details/100694207