-
2021-07-19 18:42:50
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
console.log(menuButtonInfo ) 打印menuButtonInfo就可以获取到按钮的详情信息
推荐写在页面生命周期的onReady里 onLoad里面有可能获取不到
参考官方网址:https://uniapp.dcloud.io/api/ui/menuButton?id=getmenubuttonboundingclientrect
更多相关内容 -
uni-app获取省市区详细位置信息
2021-01-20 14:01:38一个是可以根据地图搜索定位获取省市区详细地址; 另外一种也可以通过picker省市区选择器来实现手动选择问题; 最后在实现功能的前提下把代码封装了一下,代码如下 /** * 格式化位置 * @param {*} res ... -
在iOS App中实现地理位置定位的基本方法解析
2020-09-02 09:56:34主要介绍了在iOS App中实现地理位置定位的基本方法解析,包括获取当前位置和计算两点间距离等基本功能的实现,需要的朋友可以参考下 -
delphixe10app实现当前位置定位
2018-12-21 15:48:57在delphixe10平台上开发,实现app端的实时位置定位查询。 -
uni-app APP端实现点击获取经纬度、地址,并显示markers
2021-01-12 17:59:58uni-app的APP端实现的点击获取map经纬度和地址,并在点击的地方显示markers。这里要注意,在打包成正式的app,需要申请安卓和IOS高德appkey。并且将manigfest.json->App模块配置->Maps->高德地图勾选,同时...uni-app的APP端实现的点击获取map经纬度和地址,并在点击的地方显示markers。这里要注意,在打包成正式的app,需要申请安卓和IOS高德appkey。并且将manigfest.json->App模块配置->Maps->高德地图勾选,同时填写对应的appkey_ios和appkey_android (这里推荐使用高德地图,因为App为高德地图,app-nvue只支持高德地图。另外选择地图、查看地图位置的API也仅支持高德地图。App端如无特殊必要,建议使用高德地图。),下面是效果图:
最终代码:
{{address}}
export default {
data() {
return {
id: 0, // 使用 marker点击事件 需要填写id
mapWidth:"300rpx",
mapHeight:"1000rpx",
windowWidth:"",
windowHeight:"",
textwidth:"",
textheight:"",
title: 'map',
latitude: '',
longitude: '',
covers: [],
controls:[{//在地图上显示控件,控件不随着地图移动
id:111,//控件id
iconPath:'../../static/image/dingwei.png',//显示的图标
position:{//控件在地图的位置
left:0,
top:0,
width:60,
height:60,
},
clickable:true
}],
address:"",
};
},
onLoad() {
this.getSystemInfo()
this.getlocation();//
},
onNavigationBarButtonTap(e) {
var that = this
uni.$emit('address', {
address:that.address,
latitude:that.latitude,
longitude:that.longitude
});
uni.navigateBack({
delta:1
})
},
methods: {
updatedmap:function(){
},
regionchange:function(e){
},
controltapfunc:function(e){
this.getlocation();
},
getSystemInfo:function(){
var that = this
uni.getSystemInfo({
success: function (res) {
that.windowWidth=res.windowWidth
that.windowHeight=res.windowHeight
that.mapWidth = that.windowWidth
that.mapHeight = that.windowHeight-80
that.textwidth = that.windowWidth
that.textheight = that.windowHeight-that.mapHeight
that.controls = [{//在地图上显示控件,控件不随着地图移动
id:111,//控件id
iconPath:'../../static/image/dingwei.png',//显示的图标
position:{//控件在地图的位置
left:that.mapWidth-70,
top:that.mapHeight-70,
width:60,
height:60
},
clickable:true
}]
}
});
},
getadd: function(res) {
var that = this;
that.latitude = res.detail.latitude
that.longitude = res.detail.longitude
that.covers = [
{
latitude: res.detail.latitude,
longitude: res.detail.longitude,
iconPath: '../../static/image/biaoji.png',
width:40,
height:40
}
]
that.$forceUpdate()
func.getLocation(res.detail.longitude,res.detail.latitude,function(result){
that.address =result.data.result.formatted_addresses.recommend
},function(err){
})
that.$forceUpdate();
},
//获取当前位置
getlocation: function() {
var that = this;
uni.getLocation({
type: 'gcj02',
success: function(res) {
that.latitude = res.latitude;
that.longitude = res.longitude;
that.covers = [
{
latitude: res.latitude,
longitude: res.longitude,
iconPath: '../../static/image/biaoji.png',
width:40,
height:40
}
]
//func.getLocation为封装的根据经纬度查询对应的地址的ajax方法
func.getLocation(res.longitude,res.latitude,function(result){
that.address = result.data.result.formatted_addresses.recommend
},function(err){
})
that.$forceUpdate();
},
fail:function(ret){
console.log(JSON.stringify(ret));
}
});
}
}
};
uni-app H5端的实现效果不一样,因为不支持点击地图得到经纬度,详情可查看 uni-app H5端实现移动地图显示当前地图中心位置的坐标和地址
-
uni-app获取当前位置并计算出某个地点距离
2021-06-01 22:41:23需要先在manifest.json配置文件开启获取位置权限 //获取当前位置 getLocation() { let location = { lat: 0, lng: 0, } return new Promise((reserve, reject) => {//因为获取位置是异步接口所以...实现思路:先通过 uni.getLocation 接口获取当前位置获取当前位置,再与点击经纬度进行计算得出相差距离。
1.获取当前位置
需要先在manifest.json配置文件开启获取位置权限
//获取当前位置 getLocation() { let location = { lat: 0, lng: 0, } return new Promise((reserve, reject) => {//因为获取位置是异步接口所以需要使用promise uni.getLocation({ success(res) { location.lat = res.latitude location.lng = res.longitude, reserve(location); }, fail(err) { reject(location );//获取失败则返回经纬坐标为0 } }) }) },
2.调用获取位置方法,计算距离
//根据金纬度计算距离 distance(lat1, lng1) { var that = this; console.log('计算地点经纬度:', lat1, lng1); this.$utils.getLocation().then((res) => { console.log('我的位置:', location); let lat2 = res.lat; let lng2 = res.lng; let rad1 = lat1 * Math.PI / 180.0; let rad2 = lat2 * Math.PI / 180.0; let a = rad1 - rad2; let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0; let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(rad1) * Math.cos( rad2) * Math.pow( Math.sin(b / 2), 2))); s = s * 6378.137; s = Math.round(s * 10000) / 10000; s = s.toString(); s = s.substring(0, s.indexOf('.') + 2); console.log('距离:', s); return s;//返回距离 }); },
效果图
-
Android 开发——获取位置
2022-03-23 15:32:38Android 开发——获取位置 写作原因 因为这个部分网络上面涉及到的内容比较杂糅,所以我打算写一下,方便以后的开发学习小白少走一些弯路。 获取手机中所有可用的位置提供器 法一 LocationManager locationManager =...Android 开发——获取位置
写作原因
因为这个部分网络上面涉及到的内容比较杂糅,所以我打算写一下,方便以后的开发学习小白少走一些弯路。
获取手机中所有可用的位置提供器
法一
LocationManager locationManager = (LocationManager)getSystemService(LOCATION_SERVICE); List<String> providerNames = locationManager.getAllProviders(); StringBuilder stringBuilder = new StringBuilder(); for (Iterator<String> iterator = providerNames.iterator(); iterator.hasNext();){ stringBuilder.append(iterator.next()+"\n"); } Log.e("location",stringBuilder.toString());
法二(此处选择了GPS定位)
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); LocationProvider locationProvider = locationManager.getProvider(LocationManager.GPS_PROVIDER); Log.e("Location",locationProvider.getName());
法三
此处为利用选择条件去获取你想要的位置提供器
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setCostAllowed(false); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria,true); Log.e("location",provider+"");
我的实现代码(仅供参考,不作解释)
onCreate内部内容
private String locationProvider; LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // 动态请求位置信息 Toast.makeText(this,"GPS or NETWORK error",Toast.LENGTH_SHORT).show(); ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION}, 1); return; } List<String> providers = locationManager.getProviders(true); if (providers.contains(LocationManager.GPS_PROVIDER)) { locationProvider = LocationManager.GPS_PROVIDER; Toast.makeText(this,"GPS",Toast.LENGTH_SHORT).show(); } else if (providers.contains(LocationManager.NETWORK_PROVIDER)) { locationProvider = LocationManager.NETWORK_PROVIDER; Toast.makeText(this,"NETWORK",Toast.LENGTH_SHORT).show(); } else if (providers.contains(LocationManager.PASSIVE_PROVIDER)){ locationProvider = LocationManager.PASSIVE_PROVIDER; Toast.makeText(this,"PASSIVE",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this,"请开启位置请求权限",Toast.LENGTH_SHORT).show(); return; } locationManager.requestLocationUpdates( locationProvider, 1000, 1, new LocationListener() { @Override public void onLocationChanged(@NonNull Location location) { } @Override public void onStatusChanged(String provider, int status, Bundle extras) { LocationListener.super.onStatusChanged(provider, status, extras); } @Override public void onProviderEnabled(@NonNull String provider) { LocationListener.super.onProviderEnabled(provider); } @Override public void onProviderDisabled(@NonNull String provider) { LocationListener.super.onProviderDisabled(provider); } } ); // Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); // Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); Location location = locationManager.getLastKnownLocation(locationProvider); locationUpdates(location);
locationUpdates函数
public void locationUpdates(Location location){ if (location!=null){ StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("location:\n"); stringBuilder.append("经度:"); stringBuilder.append(location.getLongitude()); stringBuilder.append("纬度:"); stringBuilder.append(location.getLatitude()); Toast.makeText(ShowActivity.this,stringBuilder.toString(),Toast.LENGTH_LONG).show(); }else{ Toast.makeText(ShowActivity.this,"error",Toast.LENGTH_LONG).show(); } }
-
Android——实现APP内算路导航
2022-02-19 14:00:19功能描述:通过初始化百度地图API,获取当前位置的经纬度做为起点,所输入的地址做为目的地,然后封装成Uri格式,使用隐式Intent调用百度地图APP,最终实现算路导航。 权限声明 声明导航所需要具备的权限,例如:... -
web app实现基站定位获取精确地理位置的一种简单方法
2017-08-23 12:51:20前提:这个方式只适用于在小范围提供地理位置服务,比如校园应用 做过web端地理位置定位的同学大概都知道不管是哪家地图的...误差很大,所以我想告诉大家通过一个比较简单的方法就可以在web app上实现基站定位。 -
iOS swift 在app被杀死的情况下获取(上报)位置 后台 定位 本人实测有效
2021-11-24 11:23:14iOS开发笔记 – 实时上传用户的位置(APP被杀死的情况下也要能上传) -
Android开发获取当前经纬度和详细位置信息(原生代码实现)简单案例
2022-03-28 18:36:36最新获取经纬度定位的方法。 Android开发获取当前经纬度和详细位置信息(原生代码实现)简单案例。 -
微信公众号,JS-SDK获取位置信息,并调起第三方地图App导航
2018-03-29 16:46:46微信公众号关联网页获取位置信息,可以参照《微信公众平台技术文档》-> 微信JS-SDK说明文档,官方链接地址:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115步骤一:绑定域名先... -
位置分享APP项目源码
2016-04-14 11:20:07二是如果想导航到注册的任何一个用户,除非app定时自动发送位置信息到云端,这点实现起来比较复杂,而且与我们的主题Ionic+Cordova+Bmob无关,因此就不搞这么复杂。 4、可以查看某用户的历史足迹,并在地图中标出;... -
基于H5+的方法实现APP手机文件夹得存储
2019-03-18 16:50:19目前采用得是Uni-app框架,语法是vue语法,实现IO文件夹读取采用得是H5+里面得方法。 在项目中需求把数据存储在本地,这样可以减少网络请求得次数。优化了用户交互。 看了H5+得文档后,首先我们得确定把文件存储在... -
uni-app中使用腾讯地图sdk(解析经纬度)获取用户所在位置信息
2020-12-09 19:25:44具体步骤: 1. 注册开发者账号、申请密钥、开通webserviceAPI服务、下载小程序SDK、微信后台配置... ...注意点: ... 微信公众平台中配置request请求域名,注意找对位置及域名直接分号隔开,添加成功后微信开发者工具刷新; -
安卓APP自动更新功能实现
2022-02-17 09:54:53安卓APP自动更新功能实现前言代码实现 前言 安卓App自动更新基本上是每个App都需要具备的功能,接下来介绍一下实现自动更新的步骤。 代码实现 App自动更新主要分为新版本检测、升级弹窗、下载升级包、安装app这4个... -
简单实现app进入直接跳转到指定链接页面
2021-08-04 16:00:01简单的android 首先要下载安装好Android ...import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.KeyEvent; i -
iOS 如何实现 AppStore 中App 的自动下载
2018-05-28 09:45:14这次的分享是关于如何在 AppStore 实现 App 的自动下载,理想中的目标是只需要一部手机,不需要人来干预,就可以模拟用户的真实下载,并在下载完成以后,可以自动更改手机参数,使之变为另外一部苹果手机,进行... -
安卓模拟器上无法获取位置信息解决办法
2021-01-10 21:41:26项目实训的时候模拟器上没有定位信息,只有真机上才能显示,所以一直就使用真机调试,以为是百度sdk的毛病,一直到项目结束都没解决。今天误打误撞发现了这个毛病。 擦,真机上的定位功能一直是默认打开的,所以定位... -
实现APP定位功能
2016-11-27 22:29:04前言 最近更新项目中用的百度定位SDK时遇见了一个奇葩的问题。...这篇文章我先将百度定位的实现也介绍一下,最后再分析遇到的问题及解决方案。 定位分析 目前百度定位提供了WIFI,基站,GPS等多种定位方式,适用于室 -
基于Android studio开发的智慧社区app
2020-07-08 10:10:08基于Android studio开发的智慧社区app,Android课程结课设计。包含天气接口测试,获取当前地理位置,应用权限获取 -
uniapp实战开发商城APP和小程序
2020-03-30 17:35:41课程包含Uniapp开发全端教程,课程由英特网络独家录制,购买课程后赠送后端CMS管理系统,可以修改商品及接口数据,同时CMS提供Uniapp所需要的全部API接口,包括课程内容:安卓证书申请/APP苹果打包/APP安卓打包/微信... -
uni-app 用户地理位置授权
2020-03-17 15:21:54会调用用户【使用地理位置页面】: 如果没设置 直接退出,会继续弹出确认授权页面,设置 -> 会走授权成功的回调, - > 获取用户地理信息 在app页面添加用户授权: <script> export default ... -
uniapp中的分享功能实现(APP,小程序,公众号)
2021-09-27 16:39:21uniapp中的分享功能实现(APP,小程序,公众号) 1.APP端的分享 app端的分享可以直接使用uniapp封装的方法uni.share,uni-app的App引擎已经封装了微信、QQ、微博的分享SDK,开发者可以直接调用相关功能。可以分享到... -
Uni-App 读取位置信息 不太精准
2021-06-09 10:07:49uni.getLocation({ type: 'wgs84', geocode: true, success: function(res) { console.log(res.longitude) console.log(res.latitude) ... -
为什么所有APP都想获取你的定位?
2021-04-09 10:44:28“平均每部手机每天会被 APP定位3691次,相册和个人文件每天被APP访问2432次,APP在后台每天尝试悄悄地启动783次,有超过40万个APP可以直接读取用户的剪切板。” 这是今年1月,小米MIUI隐私保护能力建设研发团队... -
vu3 createApp 的实现
2020-12-17 15:19:54createApp 源码位置:...代码实现: /** * createApp 函数 */ export const createApp = ((...args) => { const app = ensureRenderer().createApp(...args) // 开发环境 校验 -
Android 手机app三种方法获取定位地址(自带API,外接SDK,获取外网IP)
2018-04-24 19:36:13通过Android自带的API:LocationManager获取到经纬度,再通过Geocoder反地理位置查询到所在的地址。2.外接SDK,如高德SDK,百度SDK直接获得到经纬度和地址3.通过外部接口获取到外网IP,再通过百度API或者聚合数据的API... -
微信小程序 实现多次调起授权位置弹框获取用户位置
2020-09-10 20:19:21微信小程序 实现多次调起授权位置弹框获取用户位置 需求:在小程序开发过程中通常需要获取用户的位置,有时会进入页面就要授权,有时点击某个按钮时需要授权。这时我们想到直接使用官方提供的wx.getLocation()来获取...