const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px' const util = require("../../utils/util.js"); const Http = require("../../utils/HttpBasics"); const config = require("../../config/config"); const imgurl = require("../../utils/imgurl"); Page({ data: { navigationBarHeight, latitude: null, longitude: null, markers: [],//标记点 polyline: [],//路线 circles:[], }, getLocation() { let that = this; tt.getLocation({ type: "wgs84", success: function (res) { console.log(res, 9999) if (res && res.longitude && res.latitude) { that.setData({ latitude: res.latitude, longitude: res.longitude, circles:[{ latitude: res.latitude, longitude: res.longitude, radius: 400, },] }) } }, fail: error => { console.log(error); } }) }, onLoad: function (options) { let that = this; let tempMarkers = [] let polyline = [] // tt.authorize({ // scope: "scope.userLocation", // success(res) { // console.log(res, res.data); // // if (res.data["scope.userLocation"] === "ok") that.msg("您已允许授权"); // }, // fail(err) { // console.log(err); // // if (err.data["scope.userLocation"] === "auth deny") // // that.msg("您已拒绝授权"); // }, // }); that.getLocation() tempMarkers.push({ id: 1, longitude: Number(options.longitude), latitude: Number(options.latitude), title: "店铺位置", alpha: 0.6, anchorX: 0.5, anchorY: 1, }) polyline.push({ points: [ { longitude: Number(options.longitude), latitude: Number(options.latitude), } ], color: "#222222", width: 4, dottedLine: false, colorList: ["#000022", "#220000"], borderColor: "#222222", borderWidth: 0, }) that.setData({ markers: tempMarkers }) // console.log(this.data.latitude,this.data.longitude); }, onReady(e) { this.mapCtx = tt.createMapContext("myMap"); }, })