// 引用百度地图微信小程序JSAPI模块 
var bmap = require('../../libs/bmap-wx.js'); 
var app = getApp();
Page({ 
    data: { 
        markers: [], 
        latitude: '', 
        longitude: '', 
        placeData: {},
        venueUrl: app.venueUrl,
    }, 
    makertap: function(e) { 
        var that = this; 
        var id = e.markerId;
    }, 
    onLoad: function() { 
      var self = this; 
      // 新建百度地图对象 
      var BMap = new bmap.BMapWX({ 
          ak: 'qLbLh9KupfB8Ir72bkKogyvYi246rkKS' 
      }); 
      var fail = function(data) { 
        app.dialog.msg(data.msg);
      }; 
      var success = function(code,data) {
        wx.getLocation({
          altitude: 'false',
          type: 'wgs84',
          success: function (res) {
            self.setData({
              longitude: res.longitude,
              latitude: res.latitude
            })
          }
        })
        var arr = []
        for (var i = 0; i < data.data.length; i++) {
          var obj = {
            latitude: data.data[i].latitude,
            longitude: data.data[i].longitude,
            iconPath: '../../images/marker_red.png',
            callout:{
              content:data.data[i].venueName + "\r\n地址:" + data.data[i].venuePosition + "\r\n电话:" + data.data[i].venueTelephone,
              bgColor:"#fff",
              padding:"5px",
              borderRadius:"2px",
              borderWidth:"1px",
              borderColor:"#07c160",
            }
          }
          arr.push(obj)
        }
        self.setData({ 
            markers: arr 
        }); 
      }
      app.restAjax.get(app.restAjax.path('{venueUrl}/app/venuesmap/listrangevenuesinforelease', [self.data.venueUrl]),{},null,success,fail)
    }
})