Map_split.vue
2.98 KB
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
<!--
* @Author: jiangbotao
* @Date: 2019-12-09 23:17:48
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-10 16:24:38
* @FilePath: \mymapbox\src\components\Map3857.vue
-->
<template>
<div >
<div id='before' class='map'></div>
<div id='after' class='map'></div>
</div>
</template>
<script>
import mapboxgl from 'mapbox-gl';
import Compare from 'mapbox-gl-compare';
import { Logo, MapService } from '@supermap/iclient-mapboxgl';
export default {
name: 'HelloWorld',
data () {
return {
}
},
mounted(){
var host = "http://support.supermap.com.cn:8090",
chinaUrl = host + '/iserver/services/map-china400/rest/maps/China/zxyTileImage.png?z={z}&x={x}&y={y}',
chinaDarkUrl = host + '/iserver/services/map-china400/rest/maps/ChinaDark/zxyTileImage.png?z={z}&x={x}&y={y}',
attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
" with <span>© <a href='http://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
" Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
var beforeMap = new mapboxgl.Map({
container: 'before',
style: {
"version": 8,
"sources": {
"raster-tiles": {
"attribution": attribution,
"type": "raster",
"tiles": [chinaUrl],
"tileSize": 256,
},
},
"layers": [{
"id": "before",
"type": "raster",
"source": "raster-tiles",
"minzoom": 0,
"maxzoom": 22
}],
},
center: [0, 0],
zoom: 0
});
beforeMap.addControl(new mapboxgl.NavigationControl(), 'top-left');
var afterMap = new mapboxgl.Map({
container: 'after',
style: {
"version": 8,
"sources": {
"raster-tiles": {
"type": "raster",
"tiles": [chinaDarkUrl],
"tileSize": 256,
},
},
"layers": [{
"id": "after",
"type": "raster",
"source": "raster-tiles",
"minzoom": 0,
"maxzoom": 22
}],
},
center: [0, 0],
zoom: 0
});
//mapbox 卷帘(对比)控件
var map = new mapboxgl.Compare(beforeMap, afterMap, {
// Set this to enable comparing two maps by mouse movement:
// mousemove: true
});
}
}
</script>
<style scoped>
.map {
position: absolute;
height: 100%;
width: 100%;
background-color: white
}
</style>