1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
| <template>
| <div class="historyBox">
|
| <div id="mapContainer" class="mapLeft"></div>
|
|
| </div>
| </template>
|
| <script>
| import mapType from "@/utils/maptype";
| import { Map, View } from "ol";
| import Tile from "ol/layer/Tile";
| import WMTS from "ol/source/WMTS";
| import WMTSTileGrid from "ol/tilegrid/WMTS";
| import * as olProj from "ol/proj";
|
| import XYZ from "ol/source/XYZ";
|
| export default {
| name: "historyBox",
| components: {},
| data() {
| return {
| openMap: null,
|
| };
| },
| mounted() {
|
| this.initMap();
| },
| methods: {
| initMap() {
| var l1 = new Tile({
| source: new XYZ({
| url: "http://t3.tianditu.com/DataServer?T=cta_w&x={x}&y={y}&l={z}&tk=94a34772eb88317fcbf8428e10448561"// 注记
| })
| });
| var l2 = new Tile({
| source: new XYZ({
| url: "http://t3.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=94a34772eb88317fcbf8428e10448561" // 行政区划
| })
| });
| window.map = new Map({
| target: "mapContainer",
| layers: [],
| view: new View({
| center: olProj.fromLonLat([108.945951, 34.465262]),
| zoom: 5,
| }),
| controls: [],
| });
| map.addLayer(l2);
| map.addLayer(l1);
| },
| changeLeftMap(item, index) {
|
| },
| changeRightMap(item, index) {
|
| },
| },
| };
| </script>
| <style scoped>
| .historyBox {
| width: 100%;
| height: 100%;
| background-color: #fff;
| display: flex;
| }
|
| .leftBox {
| position: relative;
| width: 50%;
| }
|
| .rightBox {
| position: relative;
| width: 50%;
| }
|
| .listBox {
| position: absolute;
| right: 20px;
| bottom: 10px;
| background-color: #373737;
| }
|
| .listBox li {
| padding: 2px;
| border: 1px solid #000;
| color: white;
| }
|
| .listBox li:hover {
| background-color: #00e1ff;
| }
|
| .mapLeft {
| width: 100% !important;
| float: left;
| position: absolute;
| height: 100%;
| background-color: #fff;
| }
|
| .mapRight {
| width: 100% !important;
| float: right;
| position: absolute;
| height: 100%;
| background-color: #fff;
| }
|
| .active {
| background-color: #4590d7;
| }
| </style>
|
|