谷歌地图api 微信小程序

Location tracking and monitoring have seen a surge in modern application development with various services such as Uber heavily relying on location services that require consistency and accuracy. With businesses and corporations requiring location information and monitoring of their various assets, delivering comprehensive location solutions has been a tricky science for many developers.

位置跟踪和监视已经见证了现代应用程序开发中的迅猛发展,其中各种服务(例如Uber)严重依赖于要求一致性和准确性的位置服务。 随着企业和公司需要位置信息并监视其各种资产,提供全面的位置解决方案对于许多开发人员而言是一门棘手的科学。

Identifying the growing demand for a convenient location providing service Google introduced the Fused Location Provider API. This article will focus on using the API to track a user’s real-time location using an android application and through the example demonstrate the beauty of the API.

为了确定对方便的位置提供服务不断增长的需求,Google引入了融合位置提供程序API。 本文将重点介绍如何使用Android应用程序使用API​​跟踪用户的实时位置,并通过示例演示API的优点。

The API focuses on providing location information using a combination of a device’s GPS, Wi-Fi and internal sensors. The main selling point is that it decides in what combination to use these three resources based on the request parameters provided. In this context managing these resources is abstracted from the developer.

该API致力于结合使用设备的GPS,Wi-Fi和内部传感器来提供位置信息。 主要卖点是,它根据提供的请求参数决定以哪种组合使用这三种资源。 在这种情况下,管理这些资源是从开发人员中提取的。

A simple use case to demonstrate the capacity of the API is tracking the movement of an individual walking towards a building, entering it and then leaving. In this scenario when the person is outdoors, the GPS service will function well. However, as he enters the building the GPS signal may drop. The Fused Location Provider handles the above scenario by tracking the location outdoors via GPS and when the GPS signal drops within the building, it utilizes Wi-Fi. During the switching process from GPS to Wi-Fi, to provide a smoother transition, the device’s internal sensors are used to predict the movement. In this manner, the management of available resources to provide reliable location services in a battery efficient manner is the true power of the API.

演示API功能的一个简单用例是跟踪一个人朝建筑物走去,进入建筑物然后离开的运动。 在这种情况下,当人在户外时,GPS服务将运行良好。 但是,当他进入建筑物时,GPS信号可能会下降。 融合位置提供器通过GPS跟踪室外位置,并在GPS信号掉入建筑物内时利用Wi-Fi处理上述情况。 在从GPS切换到Wi-Fi的过程中,为了提供更平稳的过渡,设备的内部传感器用于预测运动。 以这种方式,以电池高效方式提供可用的可靠位置服务的可用资源管理是API的真正力量。

Integrating the API into your android application is a simple process. In this example, we will walk through the necessary steps required to build a simple location tracking application.

将API集成到您的android应用程序中是一个简单的过程。 在此示例中,我们将逐步完成构建简单的位置跟踪应用程序所需的必要步骤。

First, create an android project in Android Studio and within the application’s build.gradle file, ensure the following dependency is present:

首先,在Android Studio中并在应用程序的build.gradle文件中创建一个android项目,确保存在以下依赖关系:

dependencies{   implementation ‘com.google.android.gms:play-services:11.8.0’}

Secondly, within the Manifest file you must provide either the Fine or Coarse location permission by adding the below snippet:

其次,在清单文件中,您必须通过添加以下代码段来提供“精细”或“粗糙”位置权限:

<uses-permission        android:name=”android.permission.ACCESS_FINE_LOCATION”/> <uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION”/>

Now, create instances of FusedLocationProviderClient, LocationRequest and LocationCallBack in your activity.

现在,创建FusedLocationProviderClientLocationRequest的实例 和LocationCallBack 在你的活动中。

private FusedLocationProviderClient fusedLocationClient;private LocationRequest locationRequest;private LocationCallback locationCallback;@Overrideprotected void onCreate(Bundle savedInstanceState) {      fusedLocationClient =       LocationServices.getFusedLocationProviderClient(this);   }}

The LocationRequest object is used to build a location request in accordance with parameters of our use case by providing details such as the update frequency, accuracy level and battery efficiency. Create a method to build the location request based on your desired parameters. An example is provided below:

通过提供诸如更新频率,准确性级别和电池效率之类的细节, LocationRequest对象用于根据我们用例的参数构建位置请求。 创建一种方法,以根据所需参数构建位置请求。 下面提供了一个示例:

private void buildLocationRequest() {locationRequest = new LocationRequest(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(100);locationRequest.setFastestInterval(100); locationRequest.setSmallestDisplacement(1);}//Build the location callback object and obtain the location results //as demonstrated below:private void buildLocationCallBack() {  locationCallback = new LocationCallback() {    @Override    public void onLocationResult(LocationResult locationResult) {      for (Location location: locationResult.getLocations()){         String latitude = String.valueOf(location.getLatitude());         String longitude = String.valueOf(location.getLongitude());      }    }  };}

Once the locationRequest object and the locationCallBack objects are initialized, request location data by calling the FusedLocationProviderClient’s requestLocationUpdates method. Pass the locationRequest and locationCallback objects as parameters.

一旦locationRequest 对象和locationCallBack 通过调用FusedLocationProviderClient的requestLocationUpdates方法来初始化对象,请求位置数据。 将locationRequestlocationCallback对象作为参数传递。

FusedLocationProviderClient.requestLocationUpdates(   locationRequest,   locationCallback,   null);

Based on the parameters defined by the request the API will continue to provide relevant location information that can be utilized to perform numerous functions such as location monitoring and real time speed tracking.

基于请求定义的参数,API将继续提供相关的位置信息,这些位置信息可用于执行众多功能,例如位置监视和实时速度跟踪。

The Fused Location Provider API provides a convenient method to manage all underlying location technologies by abstracting their inner workings from the developer and providing high-level methods to specify the quality and accuracy of services required.

融合位置提供程序API通过从开发人员中提取其内部工作并提供高级方法来指定所需服务的质量和准确性,从而提供了一种方便的方法来管理所有基础位置技术。

What is explored here is merely a fraction of what the API provides, and Google has provided comprehensive documentation that can be used to build diverse and robust applications in the future. Follow the link below to get started:

本文所探讨的只是API提供的功能的一小部分,并且Google提供了全面的文档,可用于将来构建各种强大的应用程序。 请点击以下链接开始使用:

https://developers.google.com/location-context/fused-location-provider

https://developers.google.com/location-context/fused-location-provider

翻译自: https://medium.com/swlh/real-time-location-tracking-using-googles-fused-location-provider-api-2fc8023f2c1c

谷歌地图api 微信小程序


http://www.taodudu.cc/news/show-2890868.html

相关文章:

  • 微信小程序和uniapp开发工具
  • Andriod微信小程序自动化测试
  • android 微信 去广告插件,Xposed去除微信朋友圈广告
  • linux微信最新版无法打开问题解决
  • java版阿里云发送短信
  • 【h5移动端页面调起手机sms批量发送短信,兼容ios和android】
  • 7款免费发短信软件,看看哪一款适合你
  • 使用python完成简单的批量信息发送
  • aliyun短信及短信模板操作
  • 飞信好友发短信
  • .net 发短信案例
  • android 4.0 原生短信,Android 4.0 短信发不出去解决办法
  • java批量发短信软件_如何获得批量短信的发送短信
  • 用Python实现免费往手机发短信
  • android 短信发件箱,android将发送短信写入发件箱
  • Android - 批量发送短信的实现方式
  • 软考成绩查询入口
  • 软考证书电子版查询
  • 2022上半年软考成绩查询时间及查询方法
  • 2022上半年软考电子证书可以查询拉!
  • 计算机软考网络工程师 查询,计算机软考网络工程师考试成绩查询指南
  • 计算机软考网络工程师 查询,软考网络工程师怎么查询报名是否成功?
  • 2021年软考考核方式
  • 软考选择题整理
  • 软考 - 计算机网络
  • 全国计算机技术与软件专业技术资格(水平)考试分数查询、2022软考分数线、系统分析师分数线、软考初级中级高级分数线
  • 查到2020年软考成绩后,这些事一定要知道!
  • 软考证书查询网站
  • 高级软考
  • 20天通过软考

谷歌地图api 微信小程序_使用Google的融合位置提供程序API进行实时位置跟踪相关推荐

  1. php小程序地图处理,微信小程序 地图map详解及简单实例

    微信小程序 地图map 微信小程序map 地图属性名类型默认值说明longitudeNumber中心经度 latitudeNumber中心纬度 scaleNumber1缩放级别 markersArra ...

  2. php小程序地图处理,微信小程序地图 map

    微信小程序地图 map 微信小程序map 地图 标记点 标记点用于在地图上显示标记的位置,不能自定义图标和样式 覆盖物 覆盖物用于在地图上显示自定义图标,可自定义图标和样式 地图组件的经纬度必填, 如 ...

  3. object picker 微信小程序_七夕地图导航微信小程序

    七夕期间,开发一款七夕微信小程序,地图导航是七夕小程序一种功能,今天单独开发一款纯七夕地图导航小程序,供大家娱乐,希望大家喜欢. 准备着手实现一个小程序,功能包括--获取用户当前位置的经纬度,在地图上 ...

  4. 腾讯地图小程序服务器配置,腾讯地图实现微信小程序地图定位教程

    前言 目前腾讯位置服务提供路线规划.地图选点.地铁图.城市选择器插件四款插件产品,本篇博客主要针对地图选点功能进行实现. 开通腾讯位置服务 2.登录进入小程序后台,选择 "开发 - 开发工具 ...

  5. 腾讯地图实现微信小程序地图定位教程

    前言 目前腾讯位置服务提供路线规划.地图选点.地铁图.城市选择器插件四款插件产品,本篇博客主要针对地图选点功能进行实现. 开通腾讯位置服务 1.进入微信公众平台 2.登录进入小程序后台,选择 &quo ...

  6. 【微信小程序+echarts点亮中国地图】微信小程序echarts中国地图点亮功能

    0 小程序开发背景 1 下载官方Github项目 2 按照Echarts官网的map示例使用 3 点击事件的函数 效果图 0 小程序开发背景 前段时间在上学校的软件开发与实践B课程 因为赶上了工大百年 ...

  7. API——微信小程序前端开发工具

    API 框架提供丰富的微信原生API,可以方便的调起微信提供的能力,如获取用户信息,本地存储,支付功能等. 说明: wx.on 开头的 API 是监听某个事件发生的API接口,接受一个 CALLBA ...

  8. 用uni-app写一个使用高德地图的微信小程序

    目录 参考文档 一.准备工作 1.申请小程序key 2.微信公众平台配置合法域名 3.配置mainfest.json 4.使用到的微信小程序插件,基础类 二.开发中遇到的问题 1.无效的 app.js ...

  9. 谷歌跟风推微信小程序;中兴解禁后首获订单;Yahoo Messenger正式关闭 | 极客头条...

    「CSDN 极客头条」,是从CSDN网站延伸至官方微信公众号的特别栏目,专注于一天业界事报道.风里雨里,我们将每天为朋友们,播报最新鲜有料的新闻资讯,让所有技术人,时刻紧跟业界潮流. 快讯速知 雪中送 ...

最新文章

  1. php正则替换模板变量,php正则替换变量指定字符的方法
  2. C语言随机数生成超详解
  3. 解析Winndows 2000/XP物理内存管理
  4. WPF之Manipulation
  5. SPSS 数据的统计分析
  6. 计算机继电保护书籍,电力网络继电保护的计算机整定计算
  7. android 触摸屏校准,android实现触摸屏校准
  8. 从零开始学统计 03 | 均值,方差,标准差
  9. 关于特修斯之船(转自知乎)
  10. 【数据可视化笔记】如何选择图表?
  11. Linux常用英文总结
  12. 史上第一张黑洞真身照片终于问世——原来黑洞不是黑的...
  13. pipe管道实现进程间的通信
  14. Devops 开发运维基础篇之使用Maven构建项目
  15. CANoe的使用--CANoe常用操作(CANoe系列其一)(转载)
  16. 【RMAN】RMAN脚本中使用替换变量
  17. 面试06,[长亮科技]()(offer)、[荔枝]()FM(在确定部门和薪资)、[涂鸦智能]()(第一轮电话面半小时,待后续)、华资软件(HR面)、[广州速游]()(已挂)。至于公司怎么样不加以言论。
  18. 饥荒联机版linux服务器安装,饥荒联机版新版本服务器搭建教程(mod安装方法)
  19. 英语作文写写学校计算机房,我的学校英语作文3篇
  20. iphone数据传输已取消怎么办_iPhone被停用怎么办?iPhone如何解除停用状态?

热门文章

  1. ob集群安装部署相关
  2. 1982年版《茶馆》内容简要回顾
  3. Xmanager 5问题记录
  4. 用html设计一个时间距离查询,使用HTML5 Geolocation实现一个距离追踪器
  5. PON、EPON、GPON的区别
  6. js实现数字时钟,按钮实现暂停开始
  7. ubuntu 下 ssd磁盘检测
  8. 中国提取市场趋势报告、技术动态创新及市场预测
  9. 好习惯是成功的关键(最经典的成功思维)
  10. 使用aspose方式使excel,ppt,word进行在线预览。(无水印)