技术标签: html5 JavaScript javascript
总结:定位非常不准,并且成功率很低。
需要在https域名下调用,本地调用偶尔能成功
/**
* 高德精确定位
* @param {*} config
* https://lbs.amap.com/api/javascript-api/reference/location#m_AMap.Geolocation
*/
export function locationGaodeExact(config = {
}) {
return new Promise((res, rej) => {
AMap.plugin('AMap.Geolocation', function() {
var geolocation = new AMap.Geolocation({
enableHighAccuracy: true, //是否使用高精度定位,默认:true
timeout: 1000, //超过10秒后停止定位,默认:5s
buttonPosition: 'RB', //定位按钮的停靠位置
buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点
...config
});
geolocation.getCurrentPosition(function(status, result) {
if (status == 'complete') {
onComplete(result);
} else {
onError(result);
}
});
});
//解析定位结果
function onComplete(data) {
const {
position: {
lng, lat },
formattedAddress,
addressComponent: {
province, city, district, adcode }
} = data;
const result = {
longitude: lng,
latitude: lat,
province,
city,
district,
address: formattedAddress,
adcode // 区县code
};
console.log('location success', result);
res(result);
}
//解析定位错误信息
function onError(error) {
console.log('location error', error);
return rej(error);
}
// res({
// longitude: '120.023763,',
// latitude: '30.289903',
// city: '杭州市',
// district: '拱墅区',
// adcode: '330105'
// })
});
}
在PC端和IOS端经常定位失败,安卓定位还可以。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>高德定位 和 H5定位</title>
<style>
* {
margin: 0;
padding: 0;
}
#container {
width: 100%;
height: 500px;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=2da0409b47ac022fb666ccaa88b4c75b"></script>
<script>
// h5获取 (no)
// window.navigator.geolocation.getCurrentPosition((e) => { alert('H5-success');alert(JSON.stringify(e)) }, (e) => { alert('h5-fail') })
// var map = new AMap.Map('container', {
// resizeEnable: true
// })
// var map = new AMap.Map('container', {
// // resizeEnable: true,
// // center: [120.023763, 30.289903],
// zoom: 15,
// })
AMap.plugin('AMap.Geolocation', function () {
var geolocation = new AMap.Geolocation({
// 是否使用高精度定位,默认:true
enableHighAccuracy: true,
// 设置定位超时时间,默认:无穷大
timeout: 10000,
// 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
buttonOffset: new
文章浏览阅读810次。Blob(binary large object)是计算机界通用术语之一,表示二进制大对象。在JavaScript中,Blob通常表示二进制数据,不过,它们不一定非得是大量数据,Blob也可以表示一个小型文本文件的内容_res.blob()
文章浏览阅读2k次。需要这个?gpperfmon_install --enable --password gpmon --port 5432-bash: gpperfmon_install: command not found直接安装?unzip gpcc.zip报错Failed to connect to database postgres on 127.0.0.1:5432 as gpadmin: libgssapi_krb5.so: cannot open shared object file: No s_greenplum command center无法下载
文章浏览阅读1.5k次,点赞2次,收藏8次。本文从高速数据传输的需求出发,对高速串行LVDS(Low Voltage Differential Signaling,低压差分信号)接口电路进行研究,重点对其传输方式进行了研究分析。基于SER/DES(Serial/Deserializer,串行/解串器)设计构架下,提出了高速自同步串行传输系统的实现方法。0 引言随着信息技术的日新月异,传统的I/O接口无法满足越来越大的数据处理任务。相对于串行传输技术,采取并行传输技术,提高通道数量就能提高数据传输数率,但是会增加很多成本。而且,并行传输技术中存在_lvds总线
文章浏览阅读1.7k次。转自:http://blog.sina.com.cn/s/blog_4fc6546101011cu5.html本人系统Windows 7旗舰版,32位,采用由m文件构造动态链接库然后在visual studio中调用的方法。1. MATLAB 环境配置: 注:Matlab r2010b及以后版本才支持vs2010, 之前版本中mbuild命令输入后可能会_matlabr2012a怎么运行代码
文章浏览阅读247次。问题引入代码实现#include<iostream>#include<cstdlib>using namespace std;struct Data{ int flag;};void MergeFunction(struct Data*list,int low,int middle,int high){ //申请辅助空间 int size=high-low; struct Data*space=(struct Data*)malloc(sizeof(struc_分治法合并程序
文章浏览阅读7.9k次,点赞19次,收藏104次。从左线性正规文法出发,构造状态图注意:增设初态S,单圆圈表示例子从右线性正规文法出发,构造状态图注意:增设终态Z,双圆圈表示例子状态转换图构造左线性正规文法注意:写左线性正规文法时从终态开始例子状态转换图构造右线性正规文法注意:写右线性正规文法时从初态开始例子..._文法状态图
文章浏览阅读6.6k次,点赞5次,收藏41次。本文基于sentinel-1.8.0版本DegradeSlot:服务降级AuthoritySlot:黑白名单校验,按照字符串匹配,比较简单ClusterBuilderSlot:构建ClusterNode对象,该对象为后面统计QPS、线程数、异常、响应时间等使用。SystemSlot:校验QPS、线程数、系统负载、CPU,按照窗口统计StatisticSlot:统计处理过的请求数和线程数FlowSlot:按照自定义的流控规则检查,这个与StatisticSlot相关NodeSelectorS._sentinel原理
文章浏览阅读218次。总序广义上而言SMPC分为两种实现方式,一类是使用布尔电路表述待计算函数,然后使用通用混淆电路来实现安全多方计算。另一类是使用域上的算术电路表述待计算函数,然后使用密码学方法实现安全多方计算。Yao氏混淆电路估值方案该方案可以用于实现对任何类型的门电路的安全估值。Lindell和Pinkas对该方案进行了严格的安全论证,证明该方案在半诚实模型下是安全的。下面简介姚氏混淆电路估值方案。令$C..._电路估值密码学
文章浏览阅读533次。中文语义匹配_from eval import evaluate
文章浏览阅读3w次。Linux 查看 每个 cpu 的核心数cat /proc/cpuinfo | grep "processor" | grep "0" | wc -l_命令行 为什么查看每个cpu的核数不需要加 wc -l
文章浏览阅读1k次。问题安装 mmcv时报错 LINK : fatal error LNK1158: cannot run ‘rc.exe’原因这是找不到rc.exe导致问题解决措施在 C:\Program Files (x86)\Windows Kits\8.1\bin\x86 下找到rcdll.dll 和rc.exe复制到VC安装路径中,我的是 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin再次运行,安装成功Looking in inde_qt cannot run rc.exe
文章浏览阅读9.2k次,点赞10次,收藏78次。WPS宏开发 VBA宏转JS宏_vba转js