From a40ba543c8c5dc08669e3a37059ba39bf1ce284c Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Sun, 09 May 2021 12:50:49 +0800
Subject: [PATCH] 小程序地图

---
 public/xcxh5map/getUrlData.js |   10 +++++
 src/router/page/index.js      |   22 +++++-----
 public/xcxh5map/map.html      |   36 +++++++++++++-----
 3 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/public/xcxh5map/getUrlData.js b/public/xcxh5map/getUrlData.js
new file mode 100644
index 0000000..093ffa5
--- /dev/null
+++ b/public/xcxh5map/getUrlData.js
@@ -0,0 +1,10 @@
+function getQueryVariable(variable)
+{
+       var query = window.location.search.substring(1);
+       var vars = query.split("&");
+       for (var i=0;i<vars.length;i++) {
+               var pair = vars[i].split("=");
+               if(pair[0] == variable){return pair[1];}
+       }
+       return(false);
+}
\ No newline at end of file
diff --git a/public/xcxh5map/map.html b/public/xcxh5map/map.html
index 671da15..3afa9b5 100644
--- a/public/xcxh5map/map.html
+++ b/public/xcxh5map/map.html
@@ -7,9 +7,11 @@
 	<link rel="stylesheet" href="./leaflet.css" />
 	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
 	<script src="./leaflet.js"></script>
-	<script src="./moni.js"></script>
+	<!-- <script src="./moni.js"></script> -->
+	<script src="./getUrlData.js"></script>
 	<link rel="stylesheet" href="./MarkerCluster.css" />
 	<link rel="stylesheet" href="./MarkerCluster.Default.css" />
+	<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
 	<script src="./leaflet.markercluster-src.js"></script>
 	<title>map</title>
 	<style type="text/css">
@@ -29,9 +31,12 @@
 
 <body>
 	<div id="map"></div>
+	<script>
+		var map = null,
+			getdata = null;
+	</script>
 	<script type="text/javascript">
-		var map = null;
-		function beginJuheMap(map) {
+		function beginJuheMap(map, data) {
 			map = L.map('map', { //初始化地图
 				center: [31.87, 120.54],
 				zoom: 12,
@@ -63,9 +68,9 @@
 				busIcon = new transportIcon({
 					iconUrl: './img/red.png'
 				});
-			console.log(datalist, 43545343)
-			for (var i = 0; i < datalist.length; i++) {
-				var a = datalist[i];
+			console.log(data, 43545343)
+			for (var i = 0; i < data.length; i++) {
+				var a = data[i];
 				var title = a.title;
 				if (a.state == 0) {
 					var marker = L.marker([a.jd, a.wd], {
@@ -88,13 +93,24 @@
 			}
 			map.addLayer(markers);
 
-			markers.on('click', function (a) {
-				console.log(a.layer, 11111111111);
-			});
+			// markers.on('click', function (a) {
+			// 	console.log(a.layer, 11111111111);
+			// });
 		}
-		beginJuheMap(map);
 
 	</script>
+	<script>
+		window.onload = () => {
+			getdata = JSON.parse(decodeURI(getQueryVariable('data')));
+			// var dataListUrl = window.location.href;
+			// decodeURI(dataListUrl);
+			console.log(getdata)
+			beginJuheMap(map, getdata);
+			wx.miniProgram.getEnv(function (res) {
+				console.log(res.miniprogram) // true
+			})
+		}
+	</script>
 </body>
 
 </html>
\ No newline at end of file
diff --git a/src/router/page/index.js b/src/router/page/index.js
index 610c20b..5419a5b 100644
--- a/src/router/page/index.js
+++ b/src/router/page/index.js
@@ -118,17 +118,17 @@
       isAuth: false
     }
   },
-  {
-    path: '/xcxMap',
-    name: '地图',
-    component: () =>
-      import( /* webpackChunkName: "page" */ '@/views/dataL/xcxmap'),
-    meta: {
-      keepAlive: true,
-      isTab: false,
-      isAuth: false
-    }
-  },
+  // {
+  //   path: '/xcxMap',
+  //   name: '地图',
+  //   component: () =>
+  //     import( /* webpackChunkName: "page" */ '@/views/dataL/xcxh5map/map.html'),
+  //   meta: {
+  //     keepAlive: true,
+  //     isTab: false,
+  //     isAuth: false
+  //   }
+  // },
   {
     path: '*',
     redirect: '/404'

--
Gitblit v1.9.3