第一步通过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获得的坐标获取所在城市?的更多相关文章

  1. C# 解析百度天气数据,Rss解析百度新闻以及根据IP获取所在城市

    百度天气 接口地址:http://api.map.baidu.com/telematics/v3/weather?location=上海&output=json&ak=hXWAgbsC ...

  2. 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 ...

  3. PHP:根据IP地址获取所在城市

    文件目录: ipLocation -----qqwry ----------QQWry.Dat -----ipCity.class.php ipCity.class.php文件代码: <?php ...

  4. PHP通过访问第三方接口,根据IP地址获取所在城市

    <?php header('Content-Type:text/html;Charset=utf-8'); /** * 获取IP地址 * * @return string */ function ...

  5. 通过IP获取所在城市

    <script type="text/javascript"> var map = new BMap.Map("allmap"); var poin ...

  6. PHP 根据IP地址获取所在城市

    header('Content-Type:text/html;Charset=utf-8'); function GetIp(){ $realip = ''; $unknown = 'unknown' ...

  7. PHP 依据IP地址获取所在城市

    有这种需求,须要依据用户的IP地址,定位用户所在的城市. 本文记录性文章,无逻辑性.有这样需求的朋友.能够直接拷贝使用.直接上代码,不需赘述. <? php header('Content-Ty ...

  8. 微信小程序获取经纬度所在城市

    小程序的wx.getLocation()获得是经纬度并不包含地名,所以要通过经纬度用相应的地图转换出地名(本文使用的是百度地图) // 获取坐标 onLoad: function (options)  ...

  9. 根据IP获取所在的国家城市

    根据IP获取所在的国家城市 新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js 新浪多地域测试方法:htt ...

随机推荐

  1. 如何实现在H5里调起高德地图APP?

    http://www.cnblogs.com/milkmap/p/5912350.html 这一篇文章,将讲述如何在H5里调起高德地图APP,并展示兴趣点.适合于展示某个餐馆,商场等,让用户自行选择前 ...

  2. ZOJ:2833 Friendship(并查集+哈希)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2833 A friend is like a flower, a rose ...

  3. [LeetCode] 560. Subarray Sum Equals K_Medium

    Given an array of integers and an integer k, you need to find the total number of continuous subarra ...

  4. NOSQL学习之一:Memcached, Redis, MongoDB区别

    Redis是一个开源(BSD许可),内存存储的数据结构服务器,可用作数据库,高速缓存和消息队列代理. Memcached是一个自由开源的,高性能,分布式内存对象缓存系统. MongoDB是一个基于分布 ...

  5. 英语笔记-some words about description of girl

     what did you learn from your last class?20:09:07abc360.Draven/PHH-HA04 ☠ 2018/4/9 20:09:07 poop20:1 ...

  6. C/C++之Memcpy and memmove

    memcpy与memmove的目的都是将N个字节的源内存地址的内容拷贝到目标内存地址中. 但当源内存和目标内存存在重叠时,memcpy会出现错误,而memmove能正确地实施拷贝,但这也增加了一点点开 ...

  7. ACM题目————中位数

    题目描述 长为L的升序序列S,S[L / 2]为其中位数. 给出两个等长升序序列S1和S2,求两序列合并并排序后的中位数. 输入 多组数据,每组第一行为n,表示两个等长升序序列的长度. 接下来n行为升 ...

  8. 【翻唱】【你的名字MAD】爱你等于爱自己

    http://video.yingtu.co/0/8f606e9b-9694-4d35-a0bf-730391a3ee12.mp4 [你的名字MAD]爱你等于爱自己-原唱翻唱 http://video ...

  9. (一)MySQL登录与退出

    mysql登陆: win+r输入cmd按enter进入命令行界面: > mysql -uroot -p -P3306 -h127.0.0.1 > 输入密码后按回车 mysql退出: mys ...

  10. java练习:GUIformysql

    代码 笔记: 1.确保导入mysql-connector-java-xxxx-bin.jar 2.sql语句容易出错,例如在组合String的时候漏掉空格 3.设置jlist的方法有很多种,具体参考a ...