Browse Source

feat: save

gemercheung 1 year ago
parent
commit
aeaa149626
2 changed files with 28 additions and 31 deletions
  1. 8 18
      src/views/map/index.vue
  2. 20 13
      src/views/map/share.vue

+ 8 - 18
src/views/map/index.vue

@@ -26,10 +26,9 @@
     :loading-tip="t('common.loadingText')"
     :loading-tip="t('common.loadingText')"
   >
   >
     <MarkerCluster>
     <MarkerCluster>
-      <!-- <template v-if="form.type === 0">
+      <template v-for="(location, i) in locations" :key="i">
         <CustomMarker
         <CustomMarker
-          v-for="(location, i) in locations"
-          :key="i"
+          v-if="location.isPro"
           :options="{
           :options="{
             position: { lat: location.lat, lng: location.lng },
             position: { lat: location.lat, lng: location.lng },
             title: location.title,
             title: location.title,
@@ -39,27 +38,15 @@
         >
         >
           <div class="custom-marker">{{ location.title }}</div>
           <div class="custom-marker">{{ location.title }}</div>
         </CustomMarker>
         </CustomMarker>
-      </template>
-      <template v-else>
         <AdvancedMarker
         <AdvancedMarker
-          v-for="(location, i) in locations"
-          :key="i"
+          v-else
           :options="{
           :options="{
             position: { lat: location.lat, lng: location.lng },
             position: { lat: location.lat, lng: location.lng },
             title: location.title,
             title: location.title,
           }"
           }"
           @click="handleMarkerClick(location)"
           @click="handleMarkerClick(location)"
         />
         />
-      </template> -->
-      <AdvancedMarker
-        v-for="(location, i) in locations"
-        :key="i"
-        :options="{
-          position: { lat: location.lat, lng: location.lng },
-          title: location.title,
-        }"
-        @click="handleMarkerClick(location)"
-      />
+      </template>
     </MarkerCluster>
     </MarkerCluster>
 
 
     <CustomControl position="TOP_LEFT">
     <CustomControl position="TOP_LEFT">
@@ -150,7 +137,7 @@
     GoogleMap,
     GoogleMap,
     AdvancedMarker,
     AdvancedMarker,
     MarkerCluster,
     MarkerCluster,
-    // CustomMarker,
+    CustomMarker,
     // InfoWindow,
     // InfoWindow,
     CustomControl,
     CustomControl,
   } from 'vue3-google-map';
   } from 'vue3-google-map';
@@ -339,6 +326,9 @@
     console.log('list', list);
     console.log('list', list);
     if (list.length === 0) {
     if (list.length === 0) {
       const project = getMarkerData(data);
       const project = getMarkerData(data);
+      project.forEach((pro: any) => {
+        pro.isPro = true;
+      });
       console.log('project', project);
       console.log('project', project);
       return project;
       return project;
     } else {
     } else {

+ 20 - 13
src/views/map/share.vue

@@ -21,10 +21,9 @@
     :loading-tip="t('common.loadingText')"
     :loading-tip="t('common.loadingText')"
   >
   >
     <MarkerCluster>
     <MarkerCluster>
-      <!-- <template v-if="form.type === 0">
+      <template v-for="(location, i) in locations" :key="i">
         <CustomMarker
         <CustomMarker
-          v-for="(location, i) in locations"
-          :key="i"
+          v-if="location.isPro"
           :options="{
           :options="{
             position: { lat: location.lat, lng: location.lng },
             position: { lat: location.lat, lng: location.lng },
             title: location.title,
             title: location.title,
@@ -34,19 +33,16 @@
         >
         >
           <div class="custom-marker">{{ location.title }}</div>
           <div class="custom-marker">{{ location.title }}</div>
         </CustomMarker>
         </CustomMarker>
-      </template>
-      <template v-else>
         <AdvancedMarker
         <AdvancedMarker
-          v-for="(location, i) in locations"
-          :key="i"
+          v-else
           :options="{
           :options="{
             position: { lat: location.lat, lng: location.lng },
             position: { lat: location.lat, lng: location.lng },
             title: location.title,
             title: location.title,
           }"
           }"
           @click="handleMarkerClick(location)"
           @click="handleMarkerClick(location)"
         />
         />
-      </template> -->
-      <AdvancedMarker
+      </template>
+      <!-- <AdvancedMarker
         v-for="(location, i) in locations"
         v-for="(location, i) in locations"
         :key="i"
         :key="i"
         :options="{
         :options="{
@@ -54,7 +50,7 @@
           title: location.title,
           title: location.title,
         }"
         }"
         @click="handleMarkerClick(location)"
         @click="handleMarkerClick(location)"
-      />
+      /> -->
     </MarkerCluster>
     </MarkerCluster>
 
 
     <!-- <CustomControl position="TOP_LEFT">
     <!-- <CustomControl position="TOP_LEFT">
@@ -138,7 +134,7 @@
     GoogleMap,
     GoogleMap,
     AdvancedMarker,
     AdvancedMarker,
     MarkerCluster,
     MarkerCluster,
-    // CustomMarker,
+    CustomMarker,
     // InfoWindow,
     // InfoWindow,
     // CustomControl,
     // CustomControl,
   } from 'vue3-google-map';
   } from 'vue3-google-map';
@@ -255,8 +251,19 @@
           mapper.webSite = item.webSite;
           mapper.webSite = item.webSite;
           return mapper;
           return mapper;
         });
         });
-      console.log('getMarkerData-list', list);
-      return list;
+      if (list.length === 0) {
+        return data.map((item) => {
+          const mapper = {} as any;
+          mapper.isPro = true;
+          mapper.lat = Number(item.lat);
+          mapper.lng = Number(item.lon);
+          mapper.title = item.title;
+          mapper.webSite = item.webSite;
+          return mapper;
+        });
+      } else {
+        return list;
+      }
     } else {
     } else {
       return data.map((item) => {
       return data.map((item) => {
         const mapper = {} as any;
         const mapper = {} as any;