瀏覽代碼

加入amap

maxiaoxiao 10 月之前
父節點
當前提交
5ac9155a14
共有 5 個文件被更改,包括 115 次插入2 次删除
  1. 23 0
      .gitignore
  2. 3 0
      index.html
  3. 2 2
      manifest.json
  4. 15 0
      package.json
  5. 72 0
      pages/index/index.vue

+ 23 - 0
.gitignore

@@ -0,0 +1,23 @@
+.DS_Store
+node_modules/
+dist/
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+**/*.log
+
+tests/**/coverage/
+tests/e2e/reports
+selenium-debug.log
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.local
+
+package-lock.json
+yarn.lock

+ 3 - 0
index.html

@@ -9,6 +9,9 @@
 				'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
 				'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
 				(coverSupport ? ', viewport-fit=cover' : '') + '" />')
 				(coverSupport ? ', viewport-fit=cover' : '') + '" />')
 		</script>
 		</script>
+		<!-- <script type="text/javascript" src="./static/amap.js"></script> -->
+		<script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=303d75319b06c07e4520f06da8fabaf0">
+		</script>
 		<title></title>
 		<title></title>
 		<!--preload-links-->
 		<!--preload-links-->
 		<!--app-context-->
 		<!--app-context-->

+ 2 - 2
manifest.json

@@ -1,5 +1,5 @@
 {
 {
-    "name" : "demoq",
+    "name" : "check-uniapp",
     "appid" : "__UNI__B8FCDB7",
     "appid" : "__UNI__B8FCDB7",
     "description" : "",
     "description" : "",
     "versionName" : "1.0.0",
     "versionName" : "1.0.0",
@@ -12,7 +12,7 @@
         "appid" : "wxeeae42dfbd21bf46",
         "appid" : "wxeeae42dfbd21bf46",
         "setting" : {
         "setting" : {
             "urlCheck" : false,
             "urlCheck" : false,
-			"minified" : true
+            "minified" : true
         },
         },
         "usingComponents" : true
         "usingComponents" : true
     },
     },

+ 15 - 0
package.json

@@ -0,0 +1,15 @@
+{
+  "name": "check-uniapp",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [],
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "ol": "^10.2.1"
+  }
+}

+ 72 - 0
pages/index/index.vue

@@ -0,0 +1,72 @@
+<template>
+	<view id="container" class=""></view>
+
+</template>
+<script>
+	import 'ol/ol.css';
+	import {
+		Map,
+		View
+	} from 'ol';
+	import TileLayer from 'ol/layer/Tile';
+	import OSM from 'ol/source/OSM';
+	const getUserInfo = () => {
+		apiUserInfo().then(res => {
+			console.log(res);
+			userinfo.value = res.data
+		})
+	}
+	let map: any = null
+	export default {
+		name: "map-view",
+		data() {
+			return {
+
+			}
+		},
+		mounted() {
+			this.initAMap();
+			// this.initMap();
+		},
+		unmounted() {
+			map && map.destroy();
+		},
+		methods: {
+			initAMap() {
+				map = new AMap.Map("container", {
+					viewMode: "3D", // 是否为3D地图模式
+					zoom: 11,
+					center: [116.397428, 39.90923],
+				});
+				// 设置离线地图
+				map.setPlugins({
+					'AMap.Offline': {}
+				});
+				// 添加离线地图数据
+				map.offline.setCity('北京');
+			},
+			initMap() {
+				// 创建地图实例
+				map = new Map({
+					target: 'container',
+					layers: [
+						new TileLayer({
+							source: new OSM()
+						})
+					],
+					view: new View({
+						center: [0, 0], // 地图中心点坐标
+						zoom: 2 // 缩放级别
+					})
+				});
+			}
+		},
+
+	};
+</script>
+<style scoped>
+	#container {
+		width: 100%;
+		height: 100vh;
+	}
+</style>