-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy path02_getFeatureByIDs.html
More file actions
81 lines (79 loc) · 3.18 KB
/
02_getFeatureByIDs.html
File metadata and controls
81 lines (79 loc) · 3.18 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
<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_getFeatureByIDs"></title>
<style>
#toolbar {
position: absolute;
top: 50px;
right: 10px;
width: 240px;
text-align: center;
z-index: 1000;
border-radius: 4px;
}
</style>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="toolbar" class="panel panel-primary">
<div class='panel-heading'>
<h5 class='panel-title text-center' data-i18n="resources.title_getFeatureByIDs"></h5></div>
<div class='panel-body content'>
<input type="button" class="btn btn-default" data-i18n="[value]resources.text_query" onclick="query()"/>
<input type="button" class="btn btn-default" data-i18n="[value]resources.text_input_value_clear" onclick="clearFeatures()"/>
</div>
</div>
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
var map, resultLayer,
baseUrl = host + "/iserver/services/map-world/rest/maps/World",
url = host + "/iserver/services/data-world/rest/data";
map = L.map('map', {
preferCanvas: true,
crs: L.CRS.EPSG4326,
center: [20, 80],
maxZoom: 18,
zoom: 2
});
new L.supermap.TiledMapLayer(baseUrl).addTo(map);
function query() {
clearFeatures();
var idsParam = new L.supermap.GetFeaturesByIDsParameters({
IDs: [233, 234],
datasetNames: ["World:Countries"]
});
// new L.supermap
// .FeatureService(url)
// .getFeaturesByIDs(idsParam, function (serviceResult) {
// resultLayer = L.geoJSON(serviceResult.result.features, {
// onEachFeature: function (feature, layer) {
// layer.bindPopup("ID: " + feature.properties.SMID +
// "<br>" + resources.text_country + ":" + feature.properties.COUNTRY);
// }
// }).addTo(map);
// });
// 用法 2 Promise
new L.supermap
.FeatureService(url)
.getFeaturesByIDs(idsParam).then((serviceResult) => {
resultLayer = L.geoJSON(serviceResult.result.features, {
onEachFeature: function (feature, layer) {
layer.bindPopup("ID: " + feature.properties.SMID +
"<br>" + resources.text_country + ":" + feature.properties.COUNTRY);
}
}).addTo(map);
})
}
function clearFeatures() {
resultLayer && map.removeLayer(resultLayer);
}
</script>
</body>
</html>