ソースを参照

选择门店修改

dq 6 年 前
コミット
793c036edf
2 ファイル変更13 行追加1 行削除
  1. 12 0
      wx-mall/pages/map/map.js
  2. 1 1
      wx-mall/pages/map/map.wxml

+ 12 - 0
wx-mall/pages/map/map.js

@@ -34,6 +34,7 @@ Page({
     util.getLocation((lng, lat) => {
       util.request(api.NearbyList, { longitude: lng, latitude: lat }).then((res) => {
         let markers = [];
+        let points = [];
         let nlist = res.data;
         for (var i = 0; i < nlist.length; i++) {
           let marker = {
@@ -50,13 +51,24 @@ Page({
             distance: nlist[i].distance
           };
           markers.push(marker);
+
+          let point = {
+            latitude: nlist[i].latitude,
+            longitude: nlist[i].longitude,
+          };
+          points.push(point);
         }
 
+        this.mapCtx.includePoints({
+          points: points,
+        })
+
         that.setData({
           latitude: lat,
           longitude: lng,
           markers: markers
         })
+
       })
     })
   },

+ 1 - 1
wx-mall/pages/map/map.wxml

@@ -1,5 +1,5 @@
 <view class="map_container">
-  <map class="map" longitude="{{longitude}}" latitude="{{latitude}}" markers='{{markers}}' show-location bindmarkertap='markersClick'>
+  <map id="myMap" class="map" longitude="{{longitude}}" latitude="{{latitude}}" markers='{{markers}}' show-location bindmarkertap='markersClick'>
       <cover-view class="map-tab-bar map-foot {{isShow ? '' : 'map-hide'}}">
         <cover-view class="map-storeName">{{storeName}}</cover-view>
         <cover-view class="map-storeAddress">{{storeAddress}}</cover-view>