1. 三维定位同二维定位类似,也包括浏览器定位、IP定位、SDK辅助定位。

2. 浏览器定位

/**   * 浏览器定位   */  function geoLocation() {    var geoLocation = new BMapGL.Geolocation();    geoLocation.getCurrentPosition(function (r) {      if(this.getStatus() == BMAP_STATUS_SUCCESS){        var mk = new BMapGL.Marker(r.point);        map.addOverlay(mk);        map.panTo(r.point);        alert('您的位置:' + r.point.lng + "," + r.point.lat);      }      else {        alert('failed' + this.getStatus());      }    });  }

 

3. IP定位

/**   * IP定位   */  function cityLocation() {    function myFun(result) {      var cityName = result.name;      map.setCenter(cityName);      alert("当前城市"+cityName);    }    var myCity = new BMapGL.LocalCity();    myCity.get(myFun);  }

 

4. 辅助定位

/**   * SDK辅助定位   */  function sdkLocation() {    var geoLocation = new BMapGL.Geolocation();    geoLocation.enableSDKLocation();    geoLocation.getCurrentPosition(function (r) {      if(this.getStatus() == BMAP_STATUS_SUCCESS){        var mk = new BMapGL.Marker(r.point);        map.addOverlay(mk);        //map.panTo(r.point);        console.log('您的新位置:' + r.point.lng + "," + r.point.lat);      }      else {        alert('failed' + this.getStatus());      }    });  }
本站提供的所有下载资源均来自互联网,仅提供学习交流使用,版权归原作者所有。如需商业使用,请联系原作者获得授权。 如您发现有涉嫌侵权的内容,请联系我们 邮箱:[email protected]