javascript - 关于微信地图getlocation问题。
PHP中文网
PHP中文网 2017-04-10 17:37:18
[JavaScript讨论组]

调用getlocation就会在微信提示地理位置授权吗?文档中说可以把getlocation得到的经纬度返回给openlocation,具体是用什么方式返回呢?谢谢!

PHP中文网
PHP中文网

认证0级讲师

全部回复(1)
伊谢尔伦
wx.getLocation({
                type : 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
                success : function(res) {
                    var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
                    var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
                    var speed = res.speed; // 速度,以米/每秒计
                    var accuracy = res.accuracy; // 位置精度


                    wx.openLocation({
                        latitude : latitude,// 纬度,浮点数,范围为90 ~ -90
                        longitude : longitude, // 经度,浮点数,范围为180 ~ -180。
                        name : '', // 位置名
                        address : '', // 地址详情说明
                        scale : 1, // 地图缩放级别,整形值,范围从1~28。默认为最大
                        infoUrl : '' // 在查看位置界面底部显示的超链接,可点击跳转
                    });
                }
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号