uni-app使用应用内置地图查看位置
如图
<map> 组件的宽/高推荐写直接量,比如:750rpx,不要设置百分比值
![](https://upload-images.jianshu.io/upload_images/17801482-645f849c8f1349af.png?imageMogr2/auto-orient/strip|imageView2/2/w/455/format/webp)
//插入map组件 <map style="width: 100%; height: 289rpx;" :latitude="latitude" :longitude="longitude" :markers="covers" @tap="openMap()"></map>
//相关配置参数 data() { return { current: 0, latitude: 31.7335, longitude: 118.1024, covers: [ { latitude: 31.7335,//纬度,范围为-90~90,负数表示南纬 longitude: 118.1024,//经度,范围为-180~180,负数表示西经 } ] } }, methods:{ openMap() {//点击地图 uni.openLocation({ latitude: this.latitude, longitude: this.longitude, name:"马鞍山市含山县", address: "马鞍山市含山县" }) } }
上面写了点击事件,点击时,跳到如图页面,我们只需配置经纬度(就是地图中的红点),地址等信息name:”马鞍山市含山县”,address: “马鞍山市含山县”
![](https://upload-images.jianshu.io/upload_images/17801482-d8dd9bb5c77f70f5.png?imageMogr2/auto-orient/strip|imageView2/2/w/458/format/webp)
来源网址:https://www.jianshu.com/p/f1b8c484a79b