国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

微信小程序使用高德地圖實(shí)現(xiàn)檢索定位附近周邊的POI功能示例

這篇具有很好參考價(jià)值的文章主要介紹了微信小程序使用高德地圖實(shí)現(xiàn)檢索定位附近周邊的POI功能示例。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

1、效果圖

? ? ?微信小程序高德地圖api搜索定位,微信小程序,小程序微信小程序高德地圖api搜索定位,微信小程序,小程序

2、 實(shí)現(xiàn)過程

?1、登錄高德地圖開發(fā)者平臺(tái)?高德開放平臺(tái) | 高德地圖API,申請(qǐng)接口Key

?

2、在高德開發(fā)平臺(tái)下載微信小程序SDK,https://lbs.amap.com/api/wx/download

?解壓下載的文件得到 amap-wx.js ,在創(chuàng)建的項(xiàng)目中,新建一個(gè)名為 libs 目錄,將 amap-wx.js 文件拷貝到 libs 的本地目錄下。

3、微信小程序后臺(tái)添加安全域名(這個(gè)必須設(shè)置,不然無法使用定位功能)

登錄微信公眾平臺(tái),在 "設(shè)置" → "開發(fā)設(shè)置" 中設(shè)置 request 合法域名,將?https://restapi.amap.com?中添加進(jìn)去,如下圖所示:

微信小程序高德地圖api搜索定位,微信小程序,小程序

?

? 4、具體代碼

<template>
	<view class="content">
		<!-- 	<view class="btns">
			<view @click="back">取 消</view>
			<view @click="getCurrentLocation">獲取當(dāng)前地址</view>
		</view> -->
		<view class="inputCon">
			<view class="searchView">
				<text class="iconfont icon-sousuo"  @click="searchFn"></text>
				<input type="text" placeholder="搜索地點(diǎn)" v-model="searchWords" confirm-type="search" @confirm="searchFn" />
				<text @click="cancel">取消</text>
			</view>
		</view>
		<!-- 地圖部分 -->
		<view class="content-map">
			<map style="width: 100%;height: 100%;" v-if="mapFlafg" :latitude="latitude" :longitude="longitude" :markers="markers"
				@tap="tap"  :scale="16"  :title="title"/>
		</view>
		<!-- <view id="container"></view> -->
		<!--  搜索框 -->

		<!--  地點(diǎn)列表部分 -->
		<view class="list">
			<view class="item" v-for="(add,index) in dataTips" :key="add.id" @click="select(add,index)"
				:class="selectIndex==index?'active':''">
				<view class="name">{{add.name}}</view>
				<view class="address">{{add.district || ''}}{{add.address || ''}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	// 引入高德地圖api提供的微信小程序的接口
	import amapFile from '@/packageB/pages/map/amap-wx.130.js';
	// 創(chuàng)建地圖
	var myAmapFun = new amapFile.AMapWX({
		key: ''
	}); //key值要申請(qǐng)為 去高德地圖申請(qǐng)微信小程序的key
	// var myAmapFun = new amapFile.AMapWX({key: ''}); //key我的
	export default {
		data() {
			return {
				mapFlafg:false,
				selectIndex: undefined,
				selectAddr: {},
				searchWords: "",
				id: 1, // 使用 marker點(diǎn)擊事件 需要填寫id
				title: 'map',
				latitude: 39.91667, // 緯度
				longitude: 116.41667, // 經(jīng)度

				markers: [{
					latitude: 39.91667, // 緯度
					longitude: 116.41667, // 經(jīng)度
					width: 30,
					height: 30,
					iconPath: ''
					// iconPath: '../../static/ditu.png'
				}],
				dataTips: []
			}
		},
		onLoad() {
			var self = this;
			uni.getLocation({
				type: 'gcj02',
				success: function(res) {
					console.log(res, '當(dāng)前地址定位');
					if (res.errMsg == "getLocation:ok") {
						console.log(self.mark, 'onload里面看看');
						self.longitude = res.longitude;
						self.latitude = res.latitude;
						self.$set(self.markers[0],"longitude",res.longitude);
						self.$set(self.markers[0],"latitude",res.latitude);
						self.mapFlafg=true;
						console.log(self.markers,"markers")
						// self.markers[0].longitude = res.longitude;
						// self.markers[0].latitude = res.latitude;
					}
				},
				complete: () => {
					// 獲取當(dāng)前位置的地點(diǎn)列表
					myAmapFun.getPoiAround({
						location: self.longitude + ',' + self.latitude,
						success: (data) => {
							console.log("獲取當(dāng)前的列表", data);
							this.dataTips = data.poisData;
						},
						fail: (info) => {
							console.log(info, '點(diǎn)擊地圖錯(cuò)誤信息1')
						}
					})
				}
			});
			
		},
		methods: {
			cancel() {
				if (this.searchWords) {
					this.searchWords = "";
					myAmapFun.getPoiAround({
						location: this.markers[0].longitude + ',' + this.markers[0].latitude,
						success: (data) => {
							console.log("獲取當(dāng)前的列表", data);
							this.$nextTick(() => {
								this.dataTips = data.poisData;
							})
						},
						fail: (info) => {
							console.log(info)
						}
					})
				}
			},
			reserGeo() {
				myAmapFun.getRegeo({
					success: (data) => {
						console.log("getRegeo", data);
					},
					fail: (info) => {
						console.log(info)
					}
				})
			},
			// 根據(jù)地址列表中選擇某一個(gè)地點(diǎn)
			select(add, index) {
				if (!add) {
					return;
				}
				this.selectIndex = index;
				var location = add.location.split(",");
				console.log(location, add, '列表地點(diǎn)的經(jīng)緯度');
				this.selectAddr = {
					address: add.pname ? (add.pname + add.cityname + add.adname) : (add.district + add
						.address),
					detailAddress: add.address,
					latitude: location[1],
					longitude: location[0]
				};
				this.markers[0].latitude = +location[1];
				this.markers[0].longitude = +location[0];
				uni.setStorageSync("address", this.selectAddr.address);
				// 選擇地點(diǎn)后,將選取的地點(diǎn)傳遞到前一個(gè)頁面中
				var pages = getCurrentPages(); // 獲取所有的頁面棧
				var prevPage = pages[pages.length - 2]; // 找到上一個(gè)頁面,注意是頁面,如果是頁面中有組件,則需要通過頁面接受到數(shù)據(jù)后,再次往組件中傳遞
				prevPage.$vm.userAddress.locationAddress = this.selectAddr.address; //在上一個(gè)頁面中就可以用userAddress進(jìn)行接收
				prevPage.$vm.userAddress.detail = this.selectAddr.detailAddress; //在上一個(gè)頁面中就可以用userAddress進(jìn)行接收
				prevPage.$vm.selectAddr = this.selectAddr;
				prevPage.$vm.address = {
					province: add.pname,
					city: add.cityname,
					district: add.adname,
				}
				uni.navigateBack({
					delta: 1
				});

			},
			// 在地圖上點(diǎn)擊進(jìn)行選點(diǎn),這個(gè)選點(diǎn)在地圖縮放比例較大時(shí)無效,因?yàn)榫x的問題。
			tap(e) {
				console.log(e, '點(diǎn)擊了地圖');
				var location = e.detail.longitude + ',' + e.detail.latitude
				myAmapFun.getRegeo({
					location: location,
					success: (data) => {
						console.log("獲取指定定位信息", data);
						this.selectAddr = {
							address: data[0].regeocodeData.formatted_address,
							latitude: e.detail.latitude,
							longitude: e.detail.longitude
						};
						this.markers[0].latitude = data[0].latitude;
						this.markers[0].longitude = data[0].longitude;
						myAmapFun.getPoiAround({
							location: data[0].longitude + ',' + data[0].latitude,
							success: (data) => {
								console.log("獲取當(dāng)前的列表", data);
								this.dataTips = data.poisData;
							},
							fail: (info) => {
								console.log(info, '點(diǎn)擊地圖錯(cuò)誤信息1')
							}
						})
					},
					fail: (info) => {
						console.log(info, '點(diǎn)擊地圖錯(cuò)誤信息2');
					}
				})
			},
			// 根據(jù)內(nèi)容進(jìn)行檢索
			searchFn() {
				console.log("根據(jù)地址檢索", this.searchWords);
				myAmapFun.getInputtips({
					keywords: this.searchWords,
					location: '',
					success: (data) => {
						console.log(111, data);
						if (data && data.tips) {
							this.dataTips = data.tips;
						}
					},
					fail: data => {
						console.log(222, data);
					}
				})
			},
			// getCurrentLocation() {
			// 	let that = this
			// 	uni.getLocation({
			// 		type: 'wgs84',
			// 		success: function(res) {
			// 			console.log(res, '當(dāng)前地址定位');
			// 			if (res.errMsg == "getLocation:ok") {
			// 				console.log(that.mark, 'onload里面看看');
			// 				this.longitude = res.longitude;
			// 				this.latitude = res.latitude;
			// 				this.markers[0].longitude = res.longitude;
			// 				this.markers[0].latitude = res.latitude;
			// 			}
			// 		}
			// 	});
			// },
		}
	}
</script>

<style lang="scss" scoped>
	.btns {

		position: fixed;
		top: 0;
		left: 0;
		height: 260upx;
		width: 100%;
		background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0));
		display: flex;
		align-items: center;
		justify-content: space-between;
		z-index: 10 !important;

		view {
			border-radius: 10%;
			margin: 100upx 24upx 0;
			font-size: 30upx;

			&:first-child {
				color: #fff;
			}

			&:last-child {
				width: 100upx;
				height: 60upx;
				line-height: 60upx;
				text-align: center;
				border-radius: 10upx;
				background: #20c295;
				color: #fff;
			}
		}
	}

	.content {
		// position: relative;
		height: 100vh;
		display: flex;
		flex-direction: column;

		.content-map {
			width: 100%;
			height: 50vh;
		}

		.list {
			// flex: 0 1 calc(50vh - 10upx);
			border-radius: 30rpx;
			background-color: #fff;
			// position: absolute;
			// bottom:-660rpx;
			height: calc(50vh - 10upx);
			overflow-y: auto;
			width: 100%;
			margin: 0upx auto 0;
			padding-bottom: 20upx;

			.item {
				border-bottom: 2upx solid #f3f3f3;
				padding: 0 30rpx;

				&:last-child {
					border: none;
				}

				.address {
					font-size: 22upx;
					color: #666;
					margin: 10upx 0;
				}

				.name {
					font-size: 30upx;
					color: #333;
					margin-top: 10upx;
				}

				&.active {
					.name {
						font-weight: bold;
						color: #E13500;
					}

					.address {
						color: #E13500;
					}
				}
			}
		}

		.inputCon {
			flex: 0 1 108rpx;
			width: 100%;
			background: #fff;
			// top: -60upx;
			// position: relative;
			z-index: 20;
			// height: 100upx;
			display: flex;
			align-items: center;
			justify-content: center;

			.searchView {
				width: 702upx;
				height: 60upx;
				display: flex;
				align-items: center;
				line-height: 60upx;
				border-radius: 40upx;
				padding: 0 30upx;
				box-sizing: border-box;
				background: #f3f3f3;
				font-size: 26upx;

				.iconfont {
					color: #666;
					margin-right: 20upx;
				}

				input {
					flex: 1;
				}

				view {
					flex-shrink: 0;
				}
			}
		}

	}
</style>

微信小程序高德地圖api搜索定位,微信小程序,小程序

?文章來源地址http://www.zghlxwxcb.cn/news/detail-767782.html

到了這里,關(guān)于微信小程序使用高德地圖實(shí)現(xiàn)檢索定位附近周邊的POI功能示例的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 基于微信小程序Map標(biāo)簽及高德地圖開源方法實(shí)現(xiàn)路徑導(dǎo)航

    基于微信小程序Map標(biāo)簽及高德地圖開源方法實(shí)現(xiàn)路徑導(dǎo)航

    ????????微信小程序自帶地圖map標(biāo)簽,他是基于canvas畫圖功能進(jìn)行的地圖渲染,同時(shí)依賴微信的getlocation獲取經(jīng)緯度,繪制周邊地圖。地圖上可以標(biāo)點(diǎn),畫線,查看當(dāng)?shù)氐乩硇畔?。但是自帶的?dǎo)航功能模塊不能對(duì)個(gè)人開發(fā)者公開。 ????????高德地圖提供了基于微信小程

    2024年02月09日
    瀏覽(90)
  • 微信小程序,高德地圖

    微信小程序,高德地圖

    高德開放平臺(tái): 注冊(cè)賬號(hào)(https://lbs.amap.com/) 去高德地圖平臺(tái)申請(qǐng)小程序應(yīng)用的 key 應(yīng)用管理(https://console.amap.com/dev/key/app) - 我的應(yīng)用 - 創(chuàng)建新應(yīng)用 生成的 key 即可用在程序中 下載相關(guān) sdk 文件,導(dǎo)入 amap-wx.js 到項(xiàng)目中:https://lbs.amap.com/api/wx/download 創(chuàng)建 AMapWX 對(duì)象 api getRegeo 獲取

    2024年02月09日
    瀏覽(96)
  • 微信小程序---高德地圖(一)

    微信小程序---高德地圖(一)

    微信小程序調(diào)用高德API,實(shí)現(xiàn)高德地圖地位功能。 入門指南-微信小程序插件|高德地圖API (amap.com) 登錄控制臺(tái) 登錄高德開發(fā)平臺(tái)控制臺(tái)(高德開放平臺(tái) | 高德地圖API) ,進(jìn)行注冊(cè)登錄。 ?創(chuàng)建新應(yīng)用 進(jìn)入應(yīng)用管理,創(chuàng)建新應(yīng)用。 ?創(chuàng)建Key 點(diǎn)開新應(yīng)用,新應(yīng)用中添加?key,服

    2024年02月05日
    瀏覽(94)
  • 微信小程序 - 最新打開地圖選擇位置功能,支持定位附近位置、搜索全國位置及地圖標(biāo)點(diǎn)位置、檢索周邊位置,可移動(dòng)選點(diǎn)標(biāo)記位置(點(diǎn)擊選擇位置后,獲取位置精確詳細(xì)地址及名稱,拿到經(jīng)緯度等信息)

    微信小程序 - 最新打開地圖選擇位置功能,支持定位附近位置、搜索全國位置及地圖標(biāo)點(diǎn)位置、檢索周邊位置,可移動(dòng)選點(diǎn)標(biāo)記位置(點(diǎn)擊選擇位置后,獲取位置精確詳細(xì)地址及名稱,拿到經(jīng)緯度等信息)

    網(wǎng)上的教程都太亂了,各種老文章亂七八糟無法采用。 本文 實(shí)現(xiàn)了微信小程序開發(fā)中,打開騰訊內(nèi)置地圖進(jìn)行自動(dòng)定位,可選擇附近位置及搜索位置等,獲取到所選位置的詳細(xì)地址名稱及經(jīng)緯度等信息。 您可以直接復(fù)制示例代碼,稍微改改樣式就能用了。 如下圖真機(jī)所示,

    2024年02月15日
    瀏覽(36)
  • 使用百度地圖坐標(biāo)在微信小程序中定位顯示

    使用百度地圖坐標(biāo)在微信小程序中定位顯示

    一.需求描述:設(shè)備在上線時(shí)需要在上線點(diǎn)記錄所在地點(diǎn)的坐標(biāo)和位置描述信息 分別需要實(shí)現(xiàn)三個(gè)功能 1. 根據(jù)坐標(biāo)點(diǎn)顯示位置信息 , 圖1 中的紅色坐標(biāo)點(diǎn)跳轉(zhuǎn)到 圖2 時(shí),在騰訊地圖上標(biāo)出所在坐標(biāo)點(diǎn),并顯示地點(diǎn)信息; 2. 定位當(dāng)前所在位置 :點(diǎn)擊藍(lán)色圖標(biāo),會(huì)定位當(dāng)前所在位

    2024年02月09日
    瀏覽(94)
  • uniapp實(shí)現(xiàn)微信小程序用戶實(shí)時(shí)位置定位并顯示地圖

    uniapp實(shí)現(xiàn)微信小程序用戶實(shí)時(shí)位置定位并顯示地圖

    目前,我們可以通過一些現(xiàn)成的api來實(shí)現(xiàn)此功能。下面我將介紹一下通過騰訊位置服務(wù)來實(shí)現(xiàn)此功能的具體操作流程。 1、在Hbuilder x中對(duì)項(xiàng)目進(jìn)行權(quán)限開放 進(jìn)入到manifest.json文件中 ? 2、獲取調(diào)用騰訊位置服務(wù)所需的key 登錄騰訊地圖api: 騰訊位置服務(wù) - 立足生態(tài),連接未來

    2024年02月09日
    瀏覽(90)
  • 微信小程序引入高德地圖Demo 快速上手

    微信小程序引入高德地圖Demo 快速上手

    本文參照官方文檔進(jìn)行編寫 最后引入官方實(shí)例 最終效果 ` 注冊(cè)賬號(hào) https://lbs.amap.com/?ref=http%3A%2F%2Flbs.amap.com%2Fdev%2F#/ 獲取Key教程 https://lbs.amap.com/api/wx/guide/create-project/get-key/ 訪問網(wǎng)址 https://github.com/amap-demo/wx-regeo-poiaround-weather 下載微信小程序?qū)嵗?用微信開發(fā)者工具打開 打開

    2024年02月11日
    瀏覽(109)
  • 微信小程序---- 外賣小程序查看實(shí)時(shí)地圖路線(騎手端&用戶端)【高德地圖】

    微信小程序---- 外賣小程序查看實(shí)時(shí)地圖路線(騎手端&用戶端)【高德地圖】

    前言:1. 在小程序中需要使用map組件,文檔鏈接:https://developers.weixin.qq.com/miniprogram/dev/component/map.html 2.使用的是高德地圖,所以需要引進(jìn)相關(guān)的js,下載鏈接:https://lbs.amap.com/api/wx/download 3.去往高德官方申請(qǐng)需要用的key,操作鏈接:https://lbs.amap.com/api/wx/guide/create-project/get-key

    2024年02月16日
    瀏覽(95)
  • 【微信小程序】微信小程序集成高德衛(wèi)星地圖完成多邊形繪制與截圖保存

    【微信小程序】微信小程序集成高德衛(wèi)星地圖完成多邊形繪制與截圖保存

    目錄 功能需求 使用的技術(shù)點(diǎn) 注意點(diǎn) 實(shí)現(xiàn)步驟 代碼 微信小程序-地圖所在的wxml 微信小程序-地圖所在的js 微信小程序-展示截圖結(jié)果的wxml 微信小程序-展示截圖結(jié)果的js H5-地圖所在的html 完成效果? 參考文檔 感謝閱讀,歡迎討論 打開頁面展示衛(wèi)星地圖,用戶自行在地圖上繪制

    2024年02月06日
    瀏覽(965)
  • uni微信小程序跳入外鏈(以高德地圖為例)

    uni微信小程序跳入外鏈(以高德地圖為例)

    前瞻:vue項(xiàng)目在跳轉(zhuǎn)外部鏈接時(shí)一般使用:window.open 或者 href 都離不開window這一屬性,但總所周知 微信小程序并不存在 window這一屬性,所以在這個(gè)時(shí)候我們需要加以變通 方法1: 1:跳入外部鏈接,此鏈接應(yīng)該是 https加域名的鏈接,如果不是https的 那不可以 2:配置 將你所需

    2024年02月20日
    瀏覽(87)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包