| | |
| | | navigator.geolocation.getCurrentPosition(success, error, options);
|
| | |
|
| | | function success(position) {
|
| | | geoconv({coords:`${position.coords.longitude},${position.coords.latitude}`}).then(res=>{
|
| | | console.log('position', position)
|
| | | geoconv({
|
| | | coords: `${position.coords.longitude},${position.coords.latitude}`
|
| | | }).then(res => {
|
| | | console.log('res', res)
|
| | | const latitude = res.data.result[0].y;
|
| | | const longitude = res.data.result[0].x;
|
| | | var point = new BMapGL.Point(longitude, latitude); // 创建点坐标
|
| | |
| | | }
|
| | |
|
| | | function error(err) {
|
| | | console.log('err', err)
|
| | | switch (err.code) {
|
| | | case err.PERMISSION_DENIED:
|
| | | console.error("用户拒绝了位置请求。");
|
| | |
| | | this.map.addOverlay(marker);
|
| | | this.markers.push(marker);
|
| | | });
|
| | | |
| | |
|
| | | }
|
| | | }
|
| | | </script>
|