Skip to content

Commit

Permalink
新增对接 地图服务影像栅格图层 gamma 参数,新增创建临时图层示例 review by luox
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Nov 18, 2024
1 parent b55ceba commit 2fe2994
Show file tree
Hide file tree
Showing 24 changed files with 495 additions and 7 deletions.
7 changes: 7 additions & 0 deletions examples/leaflet/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ var exampleConfig = {
version: '11.2.0',
thumbnail: "chart.png",
fileName: "01_chartService"
},
{
name: "创建临时图层",
name_en: "Create temporary layer",
version: '11.3.0',
thumbnail: "createTempLayer.png",
fileName: "createTempLayer"
}
]
},
Expand Down
90 changes: 90 additions & 0 deletions examples/leaflet/createTempLayer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!--********************************************************************
* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title data-i18n="resources.title_createTempLayer"></title>
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
</head>
<style>
#toolbar {
position: absolute;
top: 50px;
right: 10px;
width: 300px;
text-align: center;
z-index: 500;
border-radius: 4px;
}
</style>
<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_createTempLayer"></h5>
</div>
<div class="panel-body content">
<div style="margin-bottom: 5px; text-align: left;">
<span data-i18n="resources.text_gammaParamBounds"></span>
</div>
<div class="panel">
<div class="input-group">
<span class="input-group-addon" data-i18n="resources.text_gamma"></span>
<input id="gammaParam" value="1" class="form-control"></input>
</div>
</div>
<input
type="button"
class="btn btn-default"
data-i18n="[value]resources.text_create"
onclick="createTempLayer()"
/>
</div>
</div>
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></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,
tempLayer,
url = host + '/iserver/services/map-World/rest/maps/World';
map = L.map('map', {
preferCanvas: true,
crs: L.CRS.EPSG4326,
center: { lon: 0, lat: 0 },
maxZoom: 18,
zoom: 2
});
createTempLayer();

function createTempLayer() {
new L.supermap.LayerInfoService(url).getLayersInfo().then((serviceResult) => {
var result = serviceResult.result;
result.subLayers.layers.map(function (layer, index) {
if (index === 15) {
layer.gamma = document.getElementById("gammaParam").value || 1;
result.subLayers.layers = [layer];
new L.supermap.LayerInfoService(url)
.setLayersInfo(
new L.supermap.SetLayersInfoParameters({
layersInfo: result
})
)
.then((res) => {
tempLayer && tempLayer.remove();
tempLayer = new L.supermap.TiledMapLayer(url, {
noWrap: true,
cacheEnabled: false,
transparent: true,
layersID: res.result.newResourceID
})
tempLayer.addTo(map);
});
}
});
});
}
</script>
</body>
</html>
Binary file added examples/leaflet/img/createTempLayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions examples/locales/en-US/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ window.examplesResources = {
"title_ugcPointPosition": "Point And Line Analysis",
"title_ugcSpatial": "Spacial Analysis",
"title_multiphaseplay": "Multiphase Play",
"title_createTempLayer": "Create Temp Layer",

"text_graphmap_shortest_analysis": "Shortest Path Analysis",
"text_startNode": "start node",
Expand Down Expand Up @@ -1696,6 +1697,9 @@ window.examplesResources = {
"text_queryDistanceLimit": "The query distance must be greater than zero",
"text_multiphaseplay": "Multiphase Play(2009-2016 years of NDVI)",
"text_2009To2016NDVI": "2009-2016 years of NDVI",
"text_create": "Create",
"text_gamma": "Gamma param",
"text_gammaParamBounds": "Gamma input bounds is 0 to 10",

"btn_previous":"Previous",
"btn_next":"Next",
Expand Down
4 changes: 4 additions & 0 deletions examples/locales/zh-CN/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ window.examplesResources = {
"title_l7_snow_particle": "雪花粒子",
"title_l7_rain_particle": "雨滴粒子",
"title_multiphaseplay": "多时相播放",
"title_createTempLayer": "创建临时图层",

"text_district_search": "行政区检索",
"text_rectangle_search": "矩形检索",
Expand Down Expand Up @@ -1652,6 +1653,9 @@ window.examplesResources = {
"text_queryDistanceLimit": "查询距离必须大于零",
"text_multiphaseplay": "多时相播放",
"text_2009To2016NDVI": "2009-2016年5月植被指数",
"text_create": "创建",
"text_gamma": "Gamma 参数",
"text_gammaParamBounds": "Gamma 数值范围为 0 到 10",



Expand Down
7 changes: 7 additions & 0 deletions examples/mapboxgl/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ var exampleConfig = {
version: '11.2.0',
thumbnail: "chart.png",
fileName: "01_chartService"
},
{
name: "创建临时图层",
name_en: "Create temporary layer",
version: '11.3.0',
thumbnail: "createTempLayer.png",
fileName: "createTempLayer"
}
]
},
Expand Down
106 changes: 106 additions & 0 deletions examples/mapboxgl/createTempLayer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!--********************************************************************
* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title data-i18n="resources.title_createTempLayer"></title>
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
</head>
<style>
#toolbar {
position: absolute;
top: 50px;
right: 10px;
width: 300px;
text-align: center;
z-index: 500;
border-radius: 4px;
}
</style>
<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_createTempLayer"></h5>
</div>
<div class="panel-body content">
<div style="margin-bottom: 5px; text-align: left;">
<span data-i18n="resources.text_gammaParamBounds"></span>
</div>
<div class="panel">
<div class="input-group">
<span class="input-group-addon" data-i18n="resources.text_gamma"></span>
<input id="gammaParam" value="1" class="form-control"></input>
</div>
</div>
<input
type="button"
class="btn btn-default"
data-i18n="[value]resources.text_create"
onclick="createTempLayer()"
/>
</div>
</div>
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
<script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
<span id="show"></span>
<script type="text/javascript">
var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
var infowin,
url = host + '/iserver/services/map-World/rest/maps/World';
var map = new mapboxgl.Map({
container: 'map',
style: {
version: 8,
sources: {},
layers: []
},
center: [0, 0],
zoom: 2
});
map.on('load', function () {
createTempLayer();
});

function createTempLayer() {
new mapboxgl.supermap.LayerInfoService(url).getLayersInfo().then((serviceResult) => {
var result = serviceResult.result;
result.subLayers.layers.map(function (layer, index) {
if (index === 15) {
layer.gamma = document.getElementById('gammaParam').value || 1;
result.subLayers.layers = [layer];
new mapboxgl.supermap.LayerInfoService(url)
.setLayersInfo(
new mapboxgl.supermap.SetLayersInfoParameters({
layersInfo: result
})
)
.then((res) => {
var result = res.result;
if (result && result.newResourceID) {
if (map.getLayer('layer')) {
map.removeLayer('layer');
map.removeSource('layer');
}
map.addLayer({
id: 'layer',
type: 'raster',
source: {
type: 'raster',
tiles: [
'http://localhost:8090/iserver/services/map-World/rest/maps/World/zxyTileImage.png?z={z}&x={x}&y={y}&transparent=true&cacheEnabled=false&noWrap=true&layersID=' +
result.newResourceID
],
tileSize: 256
}
});
}
});
}
});
});
}
</script>
</body>
</html>
Binary file added examples/mapboxgl/img/createTempLayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/maplibregl/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ var exampleConfig = {
version: '11.2.0',
thumbnail: "chart.png",
fileName: "01_chartService"
},
{
name: "创建临时图层",
name_en: "Create temporary layer",
version: '11.3.0',
thumbnail: "createTempLayer.png",
fileName: "createTempLayer"
}
]
},
Expand Down
102 changes: 102 additions & 0 deletions examples/maplibregl/createTempLayer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!--********************************************************************
* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title data-i18n="resources.title_createTempLayer"></title>
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
</head>
<style>
#toolbar {
position: absolute;
top: 50px;
right: 10px;
width: 300px;
text-align: center;
z-index: 500;
border-radius: 4px;
}
</style>
<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_createTempLayer"></h5>
</div>
<div class="panel-body content">
<div style="margin-bottom: 5px; text-align: left;">
<span data-i18n="resources.text_gammaParamBounds"></span>
</div>
<div class="panel">
<div class="input-group">
<span class="input-group-addon" data-i18n="resources.text_gamma"></span>
<input id="gammaParam" value="1" class="form-control"></input>
</div>
</div>
<input
type="button"
class="btn btn-default"
data-i18n="[value]resources.text_create"
onclick="createTempLayer()"
/>
</div>
</div>
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
<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 map = new maplibregl.Map({
container: 'map',
style: {
version: 8,
sources: {},
layers: []
},
center: [0, 0],
zoom: 2
});
createTempLayer();

function createTempLayer() {
new maplibregl.supermap.LayerInfoService(url).getLayersInfo().then((serviceResult) => {
var result = serviceResult.result;
result.subLayers.layers.map(function (layer, index) {
if (index === 15) {
layer.gamma = document.getElementById("gammaParam").value || 1;
result.subLayers.layers = [layer];
new maplibregl.supermap.LayerInfoService(url)
.setLayersInfo(
new maplibregl.supermap.SetLayersInfoParameters({
layersInfo: result
})
)
.then((res) => {
var result = res.result;
if (result && result.newResourceID) {
if (map.getLayer('layer')) {
map.removeLayer('layer');
map.removeSource('layer');
}
map.addLayer({
id: 'layer',
type: 'raster',
source: {
type: 'raster',
tiles: [
'http://localhost:8090/iserver/services/map-World/rest/maps/World/zxyTileImage.png?z={z}&x={x}&y={y}&transparent=true&cacheEnabled=false&noWrap=true&layersID=' +
result.newResourceID
],
tileSize: 256
}
});
}
});
}
});
});
}
</script>
</body>
</html>
Binary file added examples/maplibregl/img/createTempLayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/openlayers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ var exampleConfig = {
version: '11.2.0',
thumbnail: "chart.png",
fileName: "01_chartService"
},
{
name: "创建临时图层",
name_en: "Create temporary layer",
version: '11.3.0',
thumbnail: "createTempLayer.png",
fileName: "createTempLayer"
}
]
},
Expand Down
Loading

0 comments on commit 2fe2994

Please sign in to comment.