wenhongquan 3 tahun lalu
induk
melakukan
0d1da559c1

+ 22 - 19
index.html

@@ -1,31 +1,34 @@
 <!DOCTYPE html>
 <html lang="zh-CN">
-  <head>
+
+<head>
     <meta charset="UTF-8" />
     <meta http-equiv="X-UA-Compatible" content="IE=edge" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>交通运输应急指挥系统</title>
-    <link
-      rel="stylesheet"
-      href="https://minedata.cn/minemapapi/v2.1.0/minemap.css"
-    />
+    <link rel="stylesheet" href="https://minedata.cn/minemapapi/v2.1.0/minemap.css" />
     <script src="https://minedata.cn/minemapapi/v2.1.0/minemap.js"></script>
+    <!-- <script src="https://minedata.cn/minemapapi/minemap-plugins/lbs/v1/minemap-lbs.js"></script> -->
     <script>
-      minemap.domainUrl = 'https://minedata.cn';
-      minemap.dataDomainUrl = 'https://minedata.cn';
-      minemap.serverDomainUrl = 'https://minedata.cn';
-      minemap.spriteUrl = 'https://minedata.cn/minemapapi/v2.1.0/sprite/sprite';
-      minemap.serviceUrl = 'https://minedata.cn/service/';
+        minemap.domainUrl = 'https://minedata.cn';
+        minemap.dataDomainUrl = 'https://minedata.cn';
+        minemap.serverDomainUrl = 'https://minedata.cn';
+        minemap.spriteUrl = 'https://minedata.cn/minemapapi/v2.1.0/sprite/sprite';
+        minemap.serviceUrl = 'https://minedata.cn/service/';
+
+        /**
+         * key、solution设置
+         */
+        minemap.key = '77ef70465c2d4888b3a5132523494b94';
 
-      /**
-       * key、solution设置
-       */
-      minemap.key = '77ef70465c2d4888b3a5132523494b94';
-      minemap.solution = 16857;
+        window.key = '77ef70465c2d4888b3a5132523494b94';
+        minemap.solution = 16857;
     </script>
-  </head>
-  <body>
+</head>
+
+<body>
     <div id="app"></div>
     <script type="module" src="/src/main.ts"></script>
-  </body>
-</html>
+</body>
+
+</html>

+ 1 - 0
src/components/MapView/index.tsx

@@ -21,6 +21,7 @@ export default defineComponent({
         logoControl: false,
       });
       ctx.emit('update:map', map);
+      window.map = map;
     });
     return () => <div id="map" style={{ height: '100%' }} ref={mapRef} />;
   },

+ 3 - 2
src/components/QueryMap/index.tsx

@@ -5,7 +5,7 @@ import { Notify, Button } from 'vant';
 import icon_map_location from '@/assets/icons/home/icon_map_location@2x.png';
 
 // const solution = 16857;
-const key = '77ef70465c2d4888b3a5132523494b94';
+
 
 export default defineComponent({
   props: {
@@ -46,7 +46,7 @@ export default defineComponent({
         state.loading = true;
 
         fetch(
-          `https://minedata.cn/service/lbs/search/v1/keywords?keywords=${next}&city=宿迁&citylimit=true&page_idx=1&page_size=10&key=${key}`,
+          `https://minedata.cn/service/lbs/search/v1/keywords?keywords=${next}&city=宿迁&citylimit=true&page_idx=1&page_size=10&key=${window.key}`,
         )
           .then((res) => res.json())
           .then((data) => {
@@ -112,6 +112,7 @@ export default defineComponent({
                 .setLngLat([Number(longitude), Number(latitude)])
                 .setPopup(popup)
                 .addTo(state.map);
+              window._marker = state._marker;
             }
             state._marker.togglePopup();
           })

+ 124 - 23
src/views/IncidentManagementReport/index.tsx

@@ -14,6 +14,9 @@ import { useCommonStore, useIncidentStore } from '@/store';
 import QueryMap from '@/components/QueryMap';
 import { BaseMediaUrl} from '@/utils/index';
 // import MediaUpload from '@/components/MediaUpload';
+
+/** @ts-ignore */
+import icon_map_location from '@/assets/icons/home/icon_map_location@2x.png';
 import './index.scss';
 import {
   DropdownItemOption,
@@ -64,6 +67,9 @@ export default defineComponent({
     const videop = ref();
     const videopsrc = ref("");
 
+  
+
+
     const handleUpload = (file) => {
       upload(file).then((res) => {
         let type = /\w+([.jpg|.png|.gif|.swf|.bmp|.jpeg]){1}$/.test(
@@ -104,11 +110,105 @@ export default defineComponent({
 
     };
 
+    const getLocation = () => {
+      if (navigator.geolocation) {
+        navigator.geolocation.getCurrentPosition(
+          (position: GeolocationPosition) => {
+            console.log(position.coords.longitude);
+            console.log(position.coords.latitude);
+            var location = '118.28,33.97';
+            // var location = `${position.coords.longitude},${position.coords.latitude}`;
+             fetch(
+               `https://minedata.cn/service/lbs/reverse/v1/regeo?location=${location}&key=${window.key}`,
+             )
+               .then((res) => res.json())
+               .then((data) => {
+                //  console.log(data)
+                //  console.log(data.regeocodes[0].formatted_address);
+                 var ll = data.regeocodes[0].formatted_address;
+                  if (!window.map) {
+                    Notify({
+                      type: 'danger',
+                      message: '地图插件初始化异常, 请刷新页面 (Ctrl + R)',
+                    });
+
+                    return;
+                  }
+               window.map.flyTo({
+                 center: [
+                   Number(location.split(',')[0]),
+                   Number(location.split(',')[1]),
+                 ],
+                 zoom: 14,
+                 bearing: 0,
+                 pitch: 0,
+                 duration: 2000,
+               });
+                  if (window.map && window._marker) {
+                    window._marker.remove();
+                    window._marker = null;
+                  }
+                 if (window.map) {
+                   var el = document.createElement('div');
+                   el.id = 'marker';
+                   el.style.backgroundImage = `url(${icon_map_location})`;
+                   el.style.backgroundSize = 'cover';
+                   el.style.width = '24px';
+                   el.style.height = '24px';
+                   el.style.borderRadius = '50%';
+
+                   const popup = new window.minemap.Popup({
+                     closeOnClick: false,
+                     closeButton: false,
+                     offset: [0, -15],
+                   }).setText(ll);
+
+                   window._marker = new window.minemap.Marker(el, {
+                     offset: [-12, -12],
+                   })
+                     .setLngLat([
+                       Number(location.split(',')[0]),
+                       Number(location.split(',')[1]),
+                     ])
+                     .setPopup(popup)
+                     .addTo(window.map);
+                 }
+                 window._marker.togglePopup();
+                //  var ll =
+                //    data.regeocodes[0].formatted_address.replaceAll(
+                //      '江苏省宿迁市',
+                //    "");
+                 
+                 form.value.locations = location;
+                 form.value.addr = ll;
+               });
+            // minemap.service
+            //   .adminByPointData({
+            //     location: `${position.coords.longitude},${position.coords.latitude}`,
+            //   })
+            //   .then(function (response) {
+            //     console.log(response.data);
+            //   })
+            //   .catch(function (error) {
+            //     console.error(error);
+            //   });
+          },
+          (ee) => {
+            console.log(ee);
+          },
+        );
+      } else {
+        alert('浏览器不支持地理定位。');
+      }
+    };
+
     onMounted(async () => {
       commonStore.getGlobalDict('zhdd_incident_level');
       commonStore.getGlobalDict('zhdd_incident_type');
       commonStore.getGlobalDict('zhdd_org_upload');
 
+      getLocation();
+
       route.query.id && (await store.getIncidentItem(route.query.id as string));
       addr.value = detail?.value?.addr ?? '';
       if (detail.value) {
@@ -291,29 +391,7 @@ export default defineComponent({
                 form.value.locations = store.incidentDetail.baseInfo?.locations;
               }}
             />
-            <Field
-              name="上传图片"
-              label="上传图片"
-              placeholder="请输入"
-              v-slots={{
-                input: () => (
-                  <Uploader
-                    accept="image/*"
-                    v-model={form.value.pic}
-                    onDelete={(filep, detail) => {
-                      imagessrclist.splice(detail.index, 1);
-                      console.log(imagessrclist);
-                    }}
-                    afterRead={(
-                      file: UploaderFileListItem | UploaderFileListItem[],
-                    ) => {
-                      handleUpload((isArray(file) ? file[0] : file).file);
-                      return false;
-                    }}
-                  />
-                ),
-              }}
-            />
+
             <Field
               name="上传视频"
               label="上传视频"
@@ -354,6 +432,29 @@ export default defineComponent({
                 ),
               }}
             />
+            <Field
+              name="上传图片"
+              label="上传图片"
+              placeholder="请输入"
+              v-slots={{
+                input: () => (
+                  <Uploader
+                    accept="image/*"
+                    v-model={form.value.pic}
+                    onDelete={(filep, detail) => {
+                      imagessrclist.splice(detail.index, 1);
+                      console.log(imagessrclist);
+                    }}
+                    afterRead={(
+                      file: UploaderFileListItem | UploaderFileListItem[],
+                    ) => {
+                      handleUpload((isArray(file) ? file[0] : file).file);
+                      return false;
+                    }}
+                  />
+                ),
+              }}
+            />
           </CellGroup>
           <div style={{ height: '80px' }}></div>