Skip to content

Commit

Permalink
新增属性表示例
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Feb 23, 2024
1 parent f04fb12 commit 380f5da
Show file tree
Hide file tree
Showing 15 changed files with 618 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/js/include-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@
inputScript(libsurl + '/viewer-js/viewer.min.js');
inputCSS(libsurl + '/viewer-js/css/viewer.css');
}
if (inArray(includes, 'jquery-twbsPagination')) {
inputScript(libsurl + '/jquery.twbsPagination/1.4.2/jquery.twbsPagination.min.js');
}
}

function datGuiI18N() {
Expand Down
128 changes: 128 additions & 0 deletions examples/leaflet/02_attributes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<!--********************************************************************
* Copyright© 2000 - 2023 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title data-i18n="resources.title_dataAttributes"></title>
<script type="text/javascript" include="jquery,bootstrap,jquery-twbsPagination" src="../js/include-web.js"></script>
<style>
.attribute-container {
position: absolute;
bottom: 0px;
left: 0px;
width: 100%;
background: #fff;
z-index: 1000;
}
#pagination-demo {
float: right;
margin: 0;
padding-right: 20px;
padding-bottom: 20px;
}
</style>
</head>
<body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0">
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
<div class="attribute-container">
<table class="table table-bordered">
<thead>
<tr class="header"></tr>
</thead>
<tbody class="tbody"></tbody>
</table>
<ul id="pagination-demo" class="pagination-sm"></ul>
</div>
<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,
baseUrl = host + '/iserver/services/map-world/rest/maps/World',
url = host + '/iserver/services/data-world/rest/data';
var datasSource = 'World';
var dataset = 'Countries';
var pageSize = 8;
var totalCount;
var fieldInfos;
var fieldList = [];
map = L.map('map', {
preferCanvas: true,
crs: L.CRS.EPSG4326,
center: { lon: 0, lat: 0 },
maxZoom: 18,
zoom: 1
});
new L.supermap.TiledMapLayer(baseUrl).addTo(map);
query();

function query() {
var sqlParam1 = new L.supermap.GetFeaturesBySQLParameters({
queryParameter: {
name: dataset + '@' + datasSource
},
datasetNames: [datasSource + ':' + dataset]
});

new L.supermap.FeatureService(url).getFeaturesCount(sqlParam1).then(function (serviceResult) {
totalCount = serviceResult.result.totalCount;
var totalPages = Math.ceil(totalCount / pageSize);
$('#pagination-demo').twbsPagination({
totalPages: totalPages,
visiblePages: 7,
first: resources.text_firstPage,
prev: resources.text_prevPage,
next: resources.text_nextPage,
last: resources.text_lastPage,
onPageClick: function (event, page) {
$('#page-content').text('Page ' + page);
var fromIndex = (page - 1) * pageSize;
var toIndex = page * pageSize - 1;
getFeature(fromIndex, toIndex);
}
});

new L.supermap.FeatureService(url).getFeaturesDatasetInfo(sqlParam1).then(function (serviceResult) {
fieldInfos = serviceResult.result[0].fieldInfos;
fieldInfos.forEach((fieldInfo) => {
var th = document.createElement('th');
var field = fieldInfo.name;
fieldList.push(field);
th.innerHTML = fieldInfo.caption || fieldInfo.name;
document.querySelector('.header').appendChild(th);
});
getFeature(0, pageSize - 1);
});
});
}

function getFeature(fromIndex, toIndex) {
var sqlParam = new L.supermap.GetFeaturesBySQLParameters({
queryParameter: {
name: dataset + '@' + datasSource,
attributeFilter: 'SMID > 0'
},
fromIndex,
toIndex,
datasetNames: [datasSource + ':' + dataset],
returnFeaturesOnly: true
});
new L.supermap.FeatureService(url).getFeaturesBySQL(sqlParam).then(function (serviceResult) {
var tbody = document.querySelector('.tbody');
tbody.innerHTML = '';
serviceResult.result.features.features.forEach((feature) => {
var tr = document.createElement('tr');
var props = feature.properties;
fieldList.forEach((field) => {
var td = document.createElement('td');
td.innerHTML = props[field.toUpperCase()];
tr.appendChild(td);
});
tbody.appendChild(tr);
});
});
}
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions examples/leaflet/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,16 @@ var exampleConfig = {
{
name: "要素编辑",
name_en: "draw and edit features",
version: '11.2.0',
thumbnail: "drawAndEditFeatures.png",
fileName: "drawAndEditFeatures"
},
{
name: "属性表",
name_en: "attributes",
version: '11.2.0',
thumbnail: "attributes.png",
fileName: "02_attributes"
}]
},
"theme": {
Expand Down
Binary file added examples/leaflet/img/attributes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/locales/en-US/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ window.examplesResources = {
"title_websymbol_landuseOfJingjin": "Land Use of Jingjin",
"title_websymbol_landuse": "Land Use",
"title_websymbol_customWebSymbol": "Custom WebSymbol",
"title_dataAttributes": "Attributes",

"text_district_search": "Administrative region search",
"text_rectangle_search": "Rectangle retrieval",
Expand Down Expand Up @@ -1593,6 +1594,10 @@ window.examplesResources = {
"text_attributes": "Attributes",
"text_isQuerying": "Querying...",
"text_queryEmpty": "Query Empty",
"text_firstPage": "First",
"text_prevPage": "Prev",
"text_nextPage": "Next",
"text_lastPage": "Last",

"btn_previous":"Previous",
"btn_next":"Next",
Expand Down
5 changes: 5 additions & 0 deletions examples/locales/zh-CN/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ window.examplesResources = {
"title_websymbol_landuse": "土地利用",
"title_websymbol_customWebSymbol":"自定义Web符号",
"title_editFeatures": "编辑要素",
"title_dataAttributes": "属性表",

"text_district_search": "行政区检索",
"text_rectangle_search": "矩形检索",
Expand Down Expand Up @@ -1546,6 +1547,10 @@ window.examplesResources = {
"text_attributes": "物标属性",
"text_isQuerying": "查询中...",
"text_queryEmpty": "查询为空",
"text_firstPage": "首页",
"text_prevPage": "上一页",
"text_nextPage": "下一页",
"text_lastPage": "尾页",



Expand Down
153 changes: 153 additions & 0 deletions examples/mapboxgl/02_attributes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<!--********************************************************************
* Copyright© 2000 - 2023 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title data-i18n="resources.title_dataAttributes"></title>
<script type="text/javascript" include="jquery,bootstrap,jquery-twbsPagination" src="../js/include-web.js"></script>
<style>
.attribute-container {
position: absolute;
bottom: 0px;
left: 0px;
width: 100%;
background: #fff;
z-index: 1000;
}
#pagination-demo {
float: right;
margin: 0;
padding-right: 20px;
padding-bottom: 20px;
}
</style>
</head>
<body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0">
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
<div class="attribute-container">
<table class="table table-bordered">
<thead>
<tr class="header"></tr>
</thead>
<tbody class="tbody"></tbody>
</table>
<ul id="pagination-demo" class="pagination-sm"></ul>
</div>
<script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
<script type="text/javascript">
var attribution =
"<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </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 host = window.isLocal ? window.server : 'https://iserver.supermap.io';
var map,
baseUrl = host + '/iserver/services/map-world/rest/maps/World',
url = host + '/iserver/services/data-world/rest/data';
var datasSource = 'World';
var dataset = 'Countries';
var pageSize = 8;
var totalCount;
var fieldInfos;
var fieldList = [];
map = new mapboxgl.Map({
container: 'map', //div id
style: {
version: 8,
sources: {
'raster-tiles': {
attribution: attribution,
type: 'raster',
tiles: [baseUrl],
tileSize: 256
}
},
layers: [
{
id: 'simple-tiles',
type: 'raster',
source: 'raster-tiles',
maxzoom: 18
}
]
},
center: [120.143, 30.236],
zoom: 3
});
map.addControl(new mapboxgl.NavigationControl(), 'top-left');
map.addControl(new mapboxgl.supermap.LogoControl({ link: 'https://iclient.supermap.io' }), 'bottom-right');

map.on('load', function () {
query();
});

function query() {
var sqlParam1 = new mapboxgl.supermap.GetFeaturesBySQLParameters({
queryParameter: {
name: dataset + '@' + datasSource
},
datasetNames: [datasSource + ':' + dataset]
});

new mapboxgl.supermap.FeatureService(url).getFeaturesCount(sqlParam1).then(function (serviceResult) {
totalCount = serviceResult.result.totalCount;
var totalPages = Math.ceil(totalCount / pageSize);
$('#pagination-demo').twbsPagination({
totalPages: totalPages,
visiblePages: 7,
first: resources.text_firstPage,
prev: resources.text_prevPage,
next: resources.text_nextPage,
last: resources.text_lastPage,
onPageClick: function (event, page) {
$('#page-content').text('Page ' + page);
var fromIndex = (page - 1) * pageSize;
var toIndex = page * pageSize - 1;
getFeature(fromIndex, toIndex);
}
});

new mapboxgl.supermap.FeatureService(url).getFeaturesDatasetInfo(sqlParam1).then(function (serviceResult) {
fieldInfos = serviceResult.result[0].fieldInfos;
fieldInfos.forEach((fieldInfo) => {
var th = document.createElement('th');
var field = fieldInfo.name;
fieldList.push(field);
th.innerHTML = fieldInfo.caption || fieldInfo.name;
document.querySelector('.header').appendChild(th);
});
getFeature(0, pageSize - 1);
});
});
}

function getFeature(fromIndex, toIndex) {
var sqlParam = new mapboxgl.supermap.GetFeaturesBySQLParameters({
queryParameter: {
name: dataset + '@' + datasSource,
attributeFilter: 'SMID > 0'
},
fromIndex,
toIndex,
datasetNames: [datasSource + ':' + dataset],
returnFeaturesOnly: true
});
new mapboxgl.supermap.FeatureService(url).getFeaturesBySQL(sqlParam).then(function (serviceResult) {
var tbody = document.querySelector('.tbody');
tbody.innerHTML = '';
serviceResult.result.features.features.forEach((feature) => {
var tr = document.createElement('tr');
var props = feature.properties;
fieldList.forEach((field) => {
var td = document.createElement('td');
td.innerHTML = props[field.toUpperCase()];
tr.appendChild(td);
});
tbody.appendChild(tr);
});
});
}
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions examples/mapboxgl/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,16 @@ var exampleConfig = {
{
name: "要素编辑",
name_en: "draw and edit features",
version: '11.2.0',
thumbnail: "drawAndEditFeatures.png",
fileName: "drawAndEditFeatures"
},
{
name: "属性表",
name_en: "attributes",
version: '11.2.0',
thumbnail: "attributes.png",
fileName: "02_attributes"
}
]
},
Expand Down
Binary file added examples/mapboxgl/img/attributes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 380f5da

Please sign in to comment.