Browse Source

增加地理编码hook

ming 3 years ago
parent
commit
cb230f6822
1 changed files with 25 additions and 0 deletions
  1. 25 0
      hooks/useGeocoder/index.js

+ 25 - 0
hooks/useGeocoder/index.js

@@ -0,0 +1,25 @@
+export default () => {
+	const key = '6ZCBZ-I2GC4-BBIUZ-DNZVG-DXJA3-7WBS5'
+	const url = 'https://apis.map.qq.com/ws/geocoder/v1/'
+	
+	return {
+		address(address) {
+			return uni.request({
+				url,
+				data: {
+					address,
+					key
+				}
+			})
+		},
+		location(location){
+			return uni.request({
+				url,
+				data: {
+					location,
+					key
+				}
+			})
+		}
+	}
+}