Map_wz.vue
3.29 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
98
99
100
101
<!--
* @Author: jiangbotao
* @Date: 2019-12-10 22:15:53
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-15 21:21:43
* @FilePath: \supermapvue\src\components\vt\Map_wz.vue
-->
<template>
<div >
<div id="map"></div>
</div>
</template>
<script>
import mapboxgl from 'mapbox-gl';
import { Logo, FeatureService, QueryService } from '@supermap/iclient-mapboxgl';
export default {
name: 'MVT',
data () {
return {
map: null
}
},
mounted(){
this.map = new mapboxgl.Map({
container: 'map', // container id
style:
'http://127.0.0.1:8090/iserver/services/map-mvt-China_Dark/rest/maps/China_Dark/tileFeature/vectorstyles.json?type=MapBox_GL&styleonly=true',
center: [116.4, 39.9],
minZoom: 0,
zoom: 3,
// pitch: 45,
// bearing: -10
});
this.map.addControl(new mapboxgl.NavigationControl(), 'top-left');
var __this = this;
this.map.on('load', function () {
// console.log(map.getStyle().sources);
// console.log(map.getStyle().layers);
__this.map.setPaintProperty('WorldElements_R@China', 'fill-color', '#a1dab4');
__this.map.setPaintProperty('River_R@China', 'fill-color', '#fcfcfc');
var dataUrl = 'http://127.0.0.1:8090/iserver/services/data-China/rest/data/';
var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
queryParameter: {
name: "poi",
attributeFilter: "SMID > 0",
},
datasetNames: ["China:poi"],
targetEpsgCode:4326,
maxFeatures: 1500,
toIndex: -1
});
var featureService = new mapboxgl.supermap.FeatureService(dataUrl);
var features = null;
featureService.getFeaturesBySQL(sqlParam, function (serviceResult) {
features = serviceResult.result.features;
console.log(features);
__this.map.addSource("queryDatas", {
"type": "geojson",
"data": features
});
__this.map.addLayer({
"id": "queryDatasLayer",
"type": "circle",
"source": "queryDatas",
"paint": {
'circle-radius': 2,
'circle-color': '#6879FB',
// property:'value',
// stops: [
// [min,'#6879FB'],
// [min + 1/3*range,'#68FB75'],
// [min + 2/3*range, '#F94B18'],
// [max, '#F92918']
// ]
// },
'circle-opacity': 1.0,
"circle-stroke-width": 2,
"circle-stroke-color": "#007cbf",
"circle-stroke-opacity": 0.7
}
});
});
});
}
}
</script>
<style scoped>
#map {
position: absolute;
height: 100%;
width: 100%;
background-color: white
}
</style>