| | |
| | | navigator.geolocation.getCurrentPosition(success, error, options); |
| | | |
| | | function success(position) { |
| | | let that = this |
| | | const latitude = position.coords.latitude; |
| | | const longitude = position.coords.longitude; |
| | | const accuracy = position.coords.accuracy; // 精度,单位米 |
| | | |
| | | |
| | | that.latitude = latitude |
| | | that.latitude = latitude |
| | | // 在这里可以使用获取到的经纬度信息,例如在地图上显示位置等。 |
| | | } |
| | | |
| | |
| | | timeout: 5000, // 5 秒超时 |
| | | maximumAge: 0 // 不使用缓存 |
| | | }; |
| | | let res = { |
| | | longitude: 101.725544, |
| | | latitude: 26.587259 |
| | | } |
| | | // let res = { |
| | | // longitude: 101.725544, |
| | | // latitude: 26.587259 |
| | | // } |
| | | this.longitude = res.longitude; |
| | | this.latitude = res.latitude; |
| | | var point = new BMapGL.Point(res.longitude, res.latitude); // 创建点坐标 |