注意:引用微信JS

 

  //地图初始化:定位到“我”的位置
        wx.ready(function () {
            wx.checkJsApi({
                jsApiList: [
                    'getLocation'
                ],

                success: function (res) {
                    if (res.checkResult.getLocation == false) {
                        alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');
                        return;
                    }
                }
            });
            wx.error(function (res) {
                alert("接口调取失败")
            });
            wx.getLocation({
                "type": 'wgs84',
                success: function (res) {
                    latitude = res.latitude; // 纬度,
                    longitude = res.longitude; //精度
                    init(); //地图标点方法
                },
                cancel: function (res) {
                    alert('用户拒绝授权获取地理位置');
                }
            });
        });

        //

 

function init() {
            var center = new TMap.LatLng(latitude, longitude)
  ............
}