代码拉取完成,页面将自动刷新
<!--********************************************************************
* Copyright© 2000 - 2026 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_mapQueryBySQL"></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_queryBySQL"></h5></div>
<div class='panel-body content'>
<div class='panel'>
<div class='input-group'>
<span class='input-group-addon'>SQL</span>
<input min="0" class="form-control" id="sql" placeholder="SMID < 10" />
</div>
</div>
<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/maplibregl/include-maplibregl.js"></script>
<script type="text/javascript">
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
var url = host + "/iserver/services/map-world/rest/maps/World";
var attribution = "<a href='https://maplibre.org/' target='_blank'>© MapLibre </a>" +
"with <span>© <a href='https://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 map = new maplibregl.Map({
container: 'map',
style: {
"version": 8,
"sources": {
"raster-tiles": {
"attribution": attribution,
"type": "raster",
"tiles": [host + '/iserver/services/maps/rest/maps/World/zxyTileImage.png?prjCoordSys='+encodeURIComponent('{"epsgCode":3857}')+'&z={z}&x={x}&y={y}'],
"tileSize": 256,
},
},
"layers": [{
"id": "simple-tiles",
"type": "raster",
"source": "raster-tiles",
"minzoom": 0,
"maxzoom": 22
}],
},
center: [0, 0],
maxZoom: 18,
zoom: 2
});
map.addControl(new maplibregl.supermap.LogoControl({ link: "https://iclient.supermap.io" }), 'bottom-right');
map.addControl(new maplibregl.NavigationControl(), 'top-left');
map.on('load', function () {
query();
});
function query() {
clearFeatures();
var sql = document.getElementById("sql").value || "SMID < 10";
var param = new maplibregl.supermap.QueryBySQLParameters({
queryParams: {
name: "Capitals@World.1",
attributeFilter: sql
}
});
queryService = new maplibregl.supermap.QueryService(url).queryBySQL(param).then(function (serviceResult) {
var recordsets = serviceResult && serviceResult.result && serviceResult.result.recordsets;
var features = recordsets && recordsets[0] && recordsets[0].features;
map.addLayer({
"id": "points",
"type": "circle",
"paint": {
"circle-radius": 6,
"circle-color": "#007cbf",
"circle-opacity":0.1,
"circle-stroke-width":2,
"circle-stroke-color":"#007cbf",
"circle-stroke-opacity":0.5
},
"source": {
"type": "geojson",
"data": features
}
});
});
}
function clearFeatures() {
if (map.getLayer('points')) {
map.removeLayer('points');
map.removeSource('points');
}
}
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。