Skip to content

Commit 9f143a0

Browse files
新增for maplibregl service ut example 修复service ut review by luox
1 parent 0c5a853 commit 9f143a0

File tree

347 files changed

+31882
-1209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

347 files changed

+31882
-1209
lines changed

dist/maplibregl/include-maplibregl.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,20 @@
4949
}
5050

5151
//加载类库资源文件
52-
function load() {
52+
function load({ libsurl }) {
5353
var includes = (targetScript.getAttribute('include') || '').split(',');
5454
var excludes = (targetScript.getAttribute('exclude') || '').split(',');
5555
inputCSS('https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css');
5656
inputScript('https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.js');
57-
if (inArray(includes, 'L7')) {
58-
inputScript('../../dist/maplibregl/l7.js');
57+
// inputCSS('https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.css');
58+
// inputScript('https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.js');
59+
if (inArray(includes, 'draw')) {
60+
inputCSS(`${libsurl}/mapbox-gl-js/plugins/mapbox-gl-draw/1.4.1/mapbox-gl-draw.min.css`);
61+
inputScript(`${libsurl}/mapbox-gl-js/plugins/mapbox-gl-draw/1.4.1/mapbox-gl-draw.min.js`);
5962
}
60-
if (inArray(includes, 'L7Three')) {
61-
inputScript('https://cdnjs.cloudflare.com/ajax/libs/three.js/r115/three.min.js');
62-
inputScript('../../dist/maplibregl/l7-tree.js');
63+
if (inArray(includes, 'mapboxgl-draw-rectangle-drag')) {
64+
inputScript(`${libsurl}/mapboxgl-draw-rectangle-drag/1.0.1/mapboxgl-draw-rectangle-drag.browser.js`);
6365
}
64-
// dist
6566
if (!inArray(excludes, 'iclient-maplibregl')) {
6667
if (supportES6()) {
6768
inputScript('../../dist/maplibregl/iclient-maplibregl-es6.min.js');
@@ -72,12 +73,11 @@
7273
if (!inArray(excludes, 'iclient-maplibregl-css')) {
7374
inputCSS('../../dist/maplibregl/iclient-maplibregl.min.css');
7475
}
75-
if (inArray(includes, 'vue-cesium')) {
76-
inputScript('https://iclient.supermap.io/web/libs/vue-cesium/2.1.4/index.umd.min.js');
77-
}
7876
}
7977

80-
load();
78+
load({
79+
libsurl: 'https://iclient.supermap.io/web/libs'
80+
});
8181
window.isLocal = false;
8282
window.server = document.location.toString().match(/file:\/\//)
8383
? 'http://localhost:8090'
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2022 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset="UTF-8">
8+
<title data-i18n="resources.title_mapQueryByBounds"></title>
9+
<script type="text/javascript" src="../js/include-web.js"></script>
10+
</head>
11+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
12+
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
13+
<script type="text/javascript" src="../../dist/maplibregl/include-maplibregl.js"></script>
14+
<script type="text/javascript">
15+
var map;
16+
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
17+
var url = host + "/iserver/services/map-world/rest/maps/World";
18+
var attribution = "<a href='https://maplibre.org/' target='_blank'>© Maplibre </a>" +
19+
"with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
20+
" Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
21+
22+
23+
var map = new maplibregl.Map({
24+
container: 'map',
25+
style: {
26+
"version": 8,
27+
"sources": {
28+
"raster-tiles": {
29+
"attribution": attribution,
30+
"type": "raster",
31+
"tiles": [host + '/iserver/services/maps/rest/maps/World/zxyTileImage.png?prjCoordSys='+encodeURIComponent('{"epsgCode":3857}')+'&z={z}&x={x}&y={y}'],
32+
"tileSize": 256,
33+
},
34+
},
35+
"layers": [{
36+
"id": "simple-tiles",
37+
"type": "raster",
38+
"source": "raster-tiles",
39+
"minzoom": 0,
40+
"maxzoom": 22
41+
}],
42+
},
43+
center: [0, 0],
44+
maxZoom: 18,
45+
zoom: 2
46+
});
47+
// map.addControl(new maplibregl.supermap.LogoControl({ link: "https://iclient.supermap.io" }), 'bottom-right');
48+
map.addControl(new maplibregl.NavigationControl(), 'top-left');
49+
50+
map.on('load', function () {
51+
query();
52+
});
53+
54+
function query() {
55+
map.addLayer({
56+
'id': 'polygonLayer',
57+
'type': 'fill',
58+
'source': {
59+
'type': 'geojson',
60+
'data': {
61+
'type': 'Feature',
62+
'geometry': {
63+
'type': 'Polygon',
64+
'coordinates': [[[0, 0], [60, 0], [60, 39], [0, 39], [0, 0]]],
65+
}
66+
}
67+
},
68+
'paint': {
69+
'fill-outline-color': 'blue',
70+
'fill-color': 'rgba(0, 0, 255, 0.1)'
71+
72+
}
73+
});
74+
75+
var param = new maplibregl.supermap.QueryByBoundsParameters({
76+
queryParams: {name: "Capitals@World.1"},
77+
bounds: new maplibregl.LngLatBounds([0, 0], [60, 39])
78+
});
79+
80+
queryService = new maplibregl.supermap.QueryService(url).queryByBounds(param, function (serviceResult) {
81+
var recordsets = serviceResult && serviceResult.result && serviceResult.result.recordsets;
82+
83+
var features = recordsets && recordsets[0] && recordsets[0].features;
84+
map.addLayer({
85+
"id": "points",
86+
"type": "circle",
87+
"paint": {
88+
"circle-radius": 6,
89+
"circle-color": "#007cbf",
90+
"circle-opacity": 0.1,
91+
"circle-stroke-width": 2,
92+
"circle-stroke-color": "#007cbf",
93+
"circle-stroke-opacity": 0.5
94+
},
95+
"source": {
96+
"type": "geojson",
97+
"data": features
98+
}
99+
100+
});
101+
102+
});
103+
}
104+
105+
</script>
106+
</body>
107+
</html>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2022 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset="UTF-8">
8+
<title data-i18n="resources.title_mapQueryByDistance"></title>
9+
<script type="text/javascript" src="../js/include-web.js"></script>
10+
</head>
11+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
12+
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
13+
<script type="text/javascript" src="../../dist/maplibregl/include-maplibregl.js"></script>
14+
<script type="text/javascript">
15+
var decodeMarkers = [];
16+
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
17+
var url = host + "/iserver/services/map-world/rest/maps/World";
18+
var attribution = "<a href='https://maplibre.org/' target='_blank'>© Maplibre </a>" +
19+
"with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
20+
" Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
21+
var map = new maplibregl.Map({
22+
container: 'map',
23+
style: {
24+
"version": 8,
25+
"sources": {
26+
"raster-tiles": {
27+
"attribution": attribution,
28+
"type": "raster",
29+
"tiles": [host + '/iserver/services/maps/rest/maps/World/zxyTileImage.png?prjCoordSys='+encodeURIComponent('{"epsgCode":3857}')+'&z={z}&x={x}&y={y}'],
30+
"tileSize": 256,
31+
},
32+
},
33+
"layers": [{
34+
"id": "simple-tiles",
35+
"type": "raster",
36+
"source": "raster-tiles",
37+
"minzoom": 0,
38+
"maxzoom": 22
39+
}],
40+
},
41+
center: [100, 0],
42+
maxZoom: 18,
43+
zoom: 2
44+
});
45+
map.addControl(new maplibregl.supermap.LogoControl({ link: "https://iclient.supermap.io" }), 'bottom-right');
46+
map.addControl(new maplibregl.NavigationControl(), 'top-left');
47+
48+
function query() {
49+
//添加查询中心点
50+
var img = new Image();
51+
img.src = '../img/markerbig_select.png';
52+
var marker = new maplibregl.Marker(img).setLngLat([104, 30]);
53+
decodeMarkers.push(marker);
54+
55+
var point = new maplibregl.LngLat(104, 30);
56+
var param = new maplibregl.supermap.QueryByDistanceParameters({
57+
queryParams: {name: "Capitals@World.1"},
58+
distance: 10,
59+
geometry: point
60+
});
61+
62+
var queryService = new maplibregl.supermap.QueryService(url);
63+
queryService.queryByDistance(param, callback);
64+
}
65+
66+
map.on('load', function () {
67+
query();
68+
});
69+
70+
function callback(serviceResult) {
71+
var recordsets = serviceResult && serviceResult.result && serviceResult.result.recordsets;
72+
var features = recordsets && recordsets[0] && recordsets[0].features;
73+
decodeMarkers[0].addTo(map);
74+
map.addLayer({
75+
"id": "points",
76+
"type": "circle",
77+
"paint": {
78+
"circle-radius": 6,
79+
"circle-color": "#007cbf",
80+
"circle-opacity": 0.1,
81+
"circle-stroke-width": 2,
82+
"circle-stroke-color": "#007cbf",
83+
"circle-stroke-opacity": 0.5
84+
},
85+
"source": {
86+
"type": "geojson",
87+
"data": features
88+
}
89+
});
90+
}
91+
</script>
92+
</body>
93+
</html>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2022 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset="UTF-8">
8+
<title data-i18n="resources.title_mapQueryByGeometry"></title>
9+
<script type="text/javascript" src="../js/include-web.js"></script>
10+
</head>
11+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
12+
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
13+
<script type="text/javascript" src="../../dist/maplibregl/include-maplibregl.js"></script>
14+
<script type="text/javascript">
15+
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
16+
var url = host + "/iserver/services/map-world/rest/maps/World";
17+
var attribution = "<a href='https://maplibre.org/' target='_blank'>© Maplibre </a>" +
18+
"with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
19+
" Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
20+
21+
var map = new maplibregl.Map({
22+
container: 'map',
23+
style: {
24+
"version": 8,
25+
"sources": {
26+
"raster-tiles": {
27+
"attribution": attribution,
28+
"type": "raster",
29+
"tiles": [host + '/iserver/services/maps/rest/maps/World/zxyTileImage.png?prjCoordSys='+encodeURIComponent('{"epsgCode":3857}')+'&z={z}&x={x}&y={y}'],
30+
"tileSize": 256,
31+
},
32+
},
33+
"layers": [{
34+
"id": "simple-tiles",
35+
"type": "raster",
36+
"source": "raster-tiles",
37+
"minzoom": 0,
38+
"maxzoom": 22
39+
}],
40+
},
41+
center: [0, 0],
42+
maxZoom: 18,
43+
zoom: 2
44+
});
45+
map.addControl(new maplibregl.supermap.LogoControl({ link: "https://iclient.supermap.io" }), 'bottom-right');
46+
map.addControl(new maplibregl.NavigationControl(), 'top-left');
47+
48+
map.on('load', function () {
49+
query();
50+
});
51+
52+
function query() {
53+
var geo = {
54+
'type': 'Feature',
55+
'geometry': {
56+
'type': 'Polygon',
57+
'coordinates': [[[0, 0], [-30, 0], [-10, 30], [0, 0]]],
58+
}
59+
};
60+
map.addLayer({
61+
'id': 'polygonLayer',
62+
'type': 'fill',
63+
'source': {
64+
'type': 'geojson',
65+
'data': geo
66+
},
67+
'paint': {
68+
'fill-outline-color': 'red',
69+
'fill-color': 'rgba(0, 0, 255, 0.1)'
70+
}
71+
});
72+
73+
var param = new maplibregl.supermap.QueryByGeometryParameters({
74+
queryParams: {name: "Capitals@World.1"},
75+
geometry: geo
76+
});
77+
78+
queryService = new maplibregl.supermap.QueryService(url).queryByGeometry(param, function (serviceResult) {
79+
var recordsets = serviceResult && serviceResult.result && serviceResult.result.recordsets;
80+
var features = recordsets && recordsets[0] && recordsets[0].features;
81+
map.addLayer({
82+
"id": "points",
83+
"type": "circle",
84+
"paint": {
85+
"circle-radius": 6,
86+
"circle-color": "#007cbf",
87+
"circle-opacity": 0.1,
88+
"circle-stroke-width": 2,
89+
"circle-stroke-color": "#007cbf",
90+
"circle-stroke-opacity": 0.5
91+
},
92+
"source": {
93+
"type": "geojson",
94+
"data": features
95+
}
96+
});
97+
});
98+
}
99+
</script>
100+
</body>
101+
</html>

0 commit comments

Comments
 (0)