123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- var util = require('../../utils/util.js');
- var api = require('../../config/api.js');
- var app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // 中心点纬度、经度
- latitude: "",
- longitude: "",
- // 标记点 当前位置
- markers: [],
- isShow: true,
- storeName: "",
- storeAddress: "",
- distance: ""
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
- this.mapCtx = wx.createMapContext('myMap');
- this.mapCtx.moveToLocation();
-
- let that = this;
- util.getLocation((lng, lat) => {
- util.request(api.NearbyList, { longitude: lng, latitude: lat }).then((res) => {
- let markers = [];
- let marker = {
- iconPath: "/static/images/myAddress.png",
- id: 0,
- latitude: lat,
- longitude: lng,
- width: 35,
- height: 35,
- clickable: true,
-
- };
- markers.push(marker);
- let nlist = res.data;
- for (var i = 1; i <= nlist.length; i++) {
- let marker = {
- iconPath: "/static/images/address.png",
- id: i,
- latitude: nlist[i-1].latitude,
- longitude: nlist[i-1].longitude,
- width: 35,
- height: 35,
- clickable: true
- };
- markers.push(marker);
- }
- that.setData({
- latitude: lat,
- longitude: lng,
- markers: markers
- })
- })
- })
- },
- onReady: function () {
- // 页面渲染完成
- wx.create
- },
- onShow: function () {
- // 页面显示
-
- },
- onHide: function () {
- // 页面隐藏
- },
- onUnload: function () {
- // 页面关闭
- }
- })
|