wangxy преди 3 месеца
родител
ревизия
1e619929b2
променени са 3 файла, в които са добавени 56 реда и са изтрити 1 реда
  1. 48 0
      components/customMap/customMap.vue
  2. 8 1
      manifest.json
  3. BIN
      static/images/common/markIcon.png

+ 48 - 0
components/customMap/customMap.vue

@@ -0,0 +1,48 @@
+<template>
+	<view>
+		<map style="width: 100%; height: 300px;" :latitude="data.latitude" :longitude="data.longitude" :markers="data.covers"> </map>
+	</view>
+</template>
+
+<script setup>
+	import {
+		reactive,
+	} from "vue"
+	import myIcon from "@/static/images/common/markIcon.png"
+	import {onLoad} from "@dcloudio/uni-app"
+
+	const data = reactive({
+		id: 0, // 使用 marker点击事件 需要填写id
+		title: 'map',
+		latitude: 39.909,
+		longitude: 116.39742,
+		covers: [{
+			latitude: 39.909,
+			longitude: 116.39742,
+			iconPath: myIcon,
+		}]
+	})
+	
+	function initLocation() {
+		uni.getLocation({
+			type: 'gcj02',
+			success: function (res) {
+				data.longitude = res.longitude;
+				data.latitude = res.latitude;
+				data.covers[0].longitude = res.longitude;
+				data.covers[0].latitude = res.latitude;
+				console.log('当前位置的经度:' + res.longitude);
+				console.log('当前位置的纬度:' + res.latitude);
+			}
+		});
+	}
+	
+	onLoad(() => {
+		initLocation();
+	})
+	
+</script>
+
+<style>
+
+</style>

+ 8 - 1
manifest.json

@@ -144,7 +144,14 @@
             "mode" : "history"
         },
         "title" : "北京诚祥",
-        "template" : "template.h5.html"
+        "template" : "template.h5.html",
+        "sdkConfigs" : {
+            "maps" : {
+                "qqmap" : {
+                    "key" : "KBYBZ-FS3KZ-U2FXR-7VPDX-L7J46-23F55"
+                }
+            }
+        }
     },
     "fallbackLocale" : "zh-Hans"
 }

BIN
static/images/common/markIcon.png