uiwjs / react-baidu-map

基于 React 封装的百度地图组件,支持 React Hook,帮助你轻松的接入地图到 React 项目中。
https://uiwjs.github.io/react-baidu-map
MIT License
225 stars 22 forks source link

获取获取当前位置信息. #285

Open Jinxishihenian opened 2 years ago

Jinxishihenian commented 2 years ago

没有找到获取当前位置的API

jaywcjlove commented 2 years ago

https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference_3_0.html#a7b40

@Jinxishihenian

//获取当前位置
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
    if(this.getStatus() == BMAP_STATUS_SUCCESS){
        mk = new BMap.Marker(r.point);
        getAddress(r.point);
    }else {
        alert('failed'+this.getStatus());
    }
});
Jinxishihenian commented 2 years ago

这个库,提供这个服务吗? 类似于 https://lbsyun.baidu.com/index.php?title=jspopularGL/guide/geoloaction https://uiwjs.github.io/react-amap/#/geolocation 如果我安装官方文档的用法的话,需要将BMap对象,挂载到windows对象上.

Jinxishihenian commented 2 years ago

又翻了下文档,这个BMap对象已经挂载到windows对象上了,这么晚,谢谢了. https://uiwjs.github.io/react-baidu-map/#/api-loader