Selaa lähdekoodia

feat:baidumap

alwayssuper 6 kuukautta sitten
vanhempi
commit
46561f05a7
3 muutettua tiedostoa jossa 9 lisäystä ja 5 poistoa
  1. 1 1
      .env
  2. 6 2
      src/components/Map/index.vue
  3. 2 2
      src/views/iot/device/device/DeviceForm.vue

+ 1 - 1
.env

@@ -24,5 +24,5 @@ VITE_APP_DEFAULT_LOGIN_TENANT = 芋道源码
 VITE_APP_DEFAULT_LOGIN_USERNAME = admin
 VITE_APP_DEFAULT_LOGIN_PASSWORD = admin123
 
-# 高德地图
+# 百度地图
 VITE_BAIDU_MAP_KEY = 'efHIw2qmH8RzHPxK0z0rbCgzDVLup9LD'

+ 6 - 2
src/components/Map/index.vue

@@ -227,7 +227,11 @@ const regeoCode = (lonLat: string) => {
   emits('locateChange', lnglat)
   emits('update:center', lonLat)
 
-  // 设置标记并获取地址
+  // 先将地图中心点设置到目标位置
+  const point = new window.BMapGL.Point(lnglat[0], lnglat[1])
+  state.map.centerAndZoom(point, 16)
+
+  // 再设置标记并获取地址
   setMarker(lnglat)
   getAddress(lnglat)
 }
@@ -246,7 +250,7 @@ const getAddress = (lnglat: any) => {
   })
 }
 
-// 显式暴露方法,使其可以被父组件访问
+/** 显式暴露方法,使其可以被父组件访问 */
 defineExpose({ regeoCode })
 
 onMounted(() => {

+ 2 - 2
src/views/iot/device/device/DeviceForm.vue

@@ -93,14 +93,14 @@
                 @blur="updateLocationFromCoordinates"
               />
             </el-form-item>
-            <div class="pl-0 w-full ml-[-18px]" v-if="showMap">
+            <div class="pl-0 h-[400px] w-full ml-[-18px]" v-if="showMap">
               <Map
                 :isWrite="true"
                 :clickMap="true"
                 :center="formData.location"
                 @locateChange="handleLocationChange"
                 ref="mapRef"
-                class="h-[400px] w-full"
+                class="h-full w-full"
               />
             </div>
           </template>