Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Jinxishihenian opened this issue Sep 26, 2022 · 3 comments
Open

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

Jinxishihenian opened this issue Sep 26, 2022 · 3 comments

Comments

@Jinxishihenian
Copy link

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

@jaywcjlove
Copy link
Member

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
Copy link
Author

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

@Jinxishihenian
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants