【hbuilder】如何根据Geolocation获得的坐标获取所在城市?
第一步通过mui.plusReady【表示页面加载事件】调用hbuilder提供的百度定位
mui.plusReady(function()
{
plus.geolocation.getCurrentPosition( geoInf, function ( e ) {
},{geocode:true,provider:'amap'});
});
第二步通过geolnf 方法来获取具体的定位信息
function geoInf( position ) {
var codns = position.coords;//获取地理坐标信息;
var longt = codns.longitude;//获取到当前位置的经度
var lat = codns.latitude;//获取到当前位置的纬度;
提醒:position.address 获取的是地址集合包括省市县街道等
document.getElementById("city").value=position.address.city ;//通过具体的地址集合获取具体市名称,其他以此类推。
mui.alert(position.address.city+"=="+position.address.district+"--"+position.address.street);//城市、区、街道
}
获取当前位置方法二:
mui.plusReady(function() {
//获取MapMain传过来的值
var keyValue = plus.webview.currentWebview();
jingdu = keyValue.currentLons;
weidu = keyValue.currentLat;
tokens = keyValue.tokens;
plus.geolocation.getCurrentPosition(function(position) {
longitude = position.coords.longitude;
latitude = position.coords.latitude;
CarAddress = position.address.city + position.address.district + position.address.street;
console.log("longitude:"+longitude+"latitude:"+latitude+"CarAddress:"+CarAddress);
});
});
【hbuilder】如何根据Geolocation获得的坐标获取所在城市?的更多相关文章
- C# 解析百度天气数据,Rss解析百度新闻以及根据IP获取所在城市
百度天气 接口地址:http://api.map.baidu.com/telematics/v3/weather?location=上海&output=json&ak=hXWAgbsC ...
- ip获取所在城市名称等信息接口,及函数
函数: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 ...
- PHP:根据IP地址获取所在城市
文件目录: ipLocation -----qqwry ----------QQWry.Dat -----ipCity.class.php ipCity.class.php文件代码: <?php ...
- PHP通过访问第三方接口,根据IP地址获取所在城市
<?php header('Content-Type:text/html;Charset=utf-8'); /** * 获取IP地址 * * @return string */ function ...
- 通过IP获取所在城市
<script type="text/javascript"> var map = new BMap.Map("allmap"); var poin ...
- PHP 根据IP地址获取所在城市
header('Content-Type:text/html;Charset=utf-8'); function GetIp(){ $realip = ''; $unknown = 'unknown' ...
- PHP 依据IP地址获取所在城市
有这种需求,须要依据用户的IP地址,定位用户所在的城市. 本文记录性文章,无逻辑性.有这样需求的朋友.能够直接拷贝使用.直接上代码,不需赘述. <? php header('Content-Ty ...
- 微信小程序获取经纬度所在城市
小程序的wx.getLocation()获得是经纬度并不包含地名,所以要通过经纬度用相应的地图转换出地名(本文使用的是百度地图) // 获取坐标 onLoad: function (options) ...
- 根据IP获取所在的国家城市
根据IP获取所在的国家城市 新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js 新浪多地域测试方法:htt ...
随机推荐
- 【Cocos2dx 3.3 Lua】剪裁结点ClippingNode
参考资料: http://shahdza.blog.51cto.com/2410787/1561937 http://blog.csdn.net/jackystudio/article/det ...
- vscode 搭建react-native
vscode 搭建react-native 选择:vscode + typings + eslint * vscode: 宇宙最强IDE家族的最新产品 * typings: 基于typescirpt的 ...
- Matlab中图像处理实例:灰度变换,空域滤波,频域滤波,傅里叶变换的实现
http://blog.sciencenet.cn/blog-95484-803140.html % %图像灰度变换 % f = imread('E:\2013第一学期课程\媒体计算\实验一\Img\ ...
- Leetcode: Binary Tree Postorder Transversal
Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary ...
- 转载自(http://snailz.diandian.com/post/2012-10-24/40041265730)
PHP 5.4.8 添加系统服务命令 之前没注意,PHP 5.4.8 的安装包有自带的系统服务注册文件的 打开编译安装包,换成你自己的路径 cd /mydata/soft/php-5.4.8/ cp ...
- bootstrap 带有确定取消按钮的modal
</div><div class="modal fade" id="confirmModal" tabindex="-1" ...
- java常用功能
1.复制文件 private void fileChannelCopy(File source, File target) throws IOException { FileInputStream f ...
- AOAPC I: Beginning Algorithm Contests -- Training Guide (Rujia Liu) Chapter 3. Data Structures Fundamental Data Structures
10410 这题说的是给了一棵多叉树的 bfs遍历轨迹 和dfs 遍历 轨迹 在父节点向叶子节点扩展的时候优先遍历编号较小的节点.我还原出这课树特殊判定 根据bfs的顺序来建立这课树,用一个队列安排要 ...
- python 代码覆盖率 coverage用法
先装coverage: D:\test_python\e8_test>pip install coverageCollecting coverage Downloading https://f ...
- 页面点击,不是a标签也会刷新原因
页面点击,不是a标签也会刷新原因 点击事件冒泡,触发了a链接导致整个页面刷新了.直接阻止 事件冒泡即可 例子: $("tr .am-text-danger").click(func ...