julyL
5/15/2019 - 3:09 AM

百度地图根据ip定位

    asyncLoadJs(
      '//api.map.baidu.com/getscript?v=2.0&ak=f7udVi2GGWwP9hKG8OVGSobpNd0jsm5C&services='
    ).then(v => {
      var geolocation = new BMap.Geolocation();
      geolocation.getCurrentPosition(
        function(r) {
          console.log(r);
          if (this.getStatus() == BMAP_STATUS_SUCCESS) {
            alert('您的位置:' + r.point.lng + ',' + r.point.lat);
          } else {
            alert('failed' + this.getStatus());
          }
        },
        { enableHighAccuracy: true }
      );
    });