var app = getApp(); var config = require('../../config.js'); var url = '/MCommunity:getAllCommunity'; Page({ data: { scale: 10, tmpScale: 10, location: { latitude: 39.90846, longitude: 116.397447 }, markers: [] }, onLoad: function (options) { var that = this; wx.hideShareMenu(); wx.showLoading({ title: '加载中', }); loadData(that); }, bindregionchange:function(e){ var that = this; var MapContext = wx.createMapContext('map1'); MapContext.getScale( { success:res => { console.log(res) that.setData({tmpScale:res.scale}) console.log(that.data.tmpScale) console.log('aaa') wx.showLoading({ title: '加载中', }); loadData(that); } } ) } }); function loadData(that){ var param = {}; param.scale = that.data.tmpScale; app.ajaxPost(url, param, function (data) { var markers = []; wx.hideLoading(); console.log(data) data.forEach(element => { console.log(element) markers.push( { 'id':element.document_id, 'latitude': element.latitude, 'longitude': element.longitude, 'iconPath': '/bc/image/point2.gif', 'callout':{ 'content':element.name+"["+element.count+"]", 'color':"#ffffff", 'bgColor':'#07c160', 'padding':5, 'fontSize':"14", 'borderRadius':"6", 'textAlign':"center", 'display':'ALWAYS', 'anchorY':10 } } ) }); console.log(markers) that.setData({ markers: markers}); }) }
<view class="map-container"> <map id="map1" class="map" markers="{{markers}}" latitude="{{location.latitude}}" longitude="{{location.longitude}}" scale="{{scale}}" min-scale="10" max-scale="14" bindregionchange="bindregionchange"></map> </view>
// if($param['scale'] <= 10 ){ // $result = $this->houseDistrict($param); // }elseif($param['scale'] <= 12){ // $result = $this->houseRegion($param); // }else{ // $result = $this->houseCommunity($param); // }
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com