Skip to content

Commit f99214e

Browse files
committed
【feature】 webmap3.0对接; review by songym
1 parent 6aabe7b commit f99214e

File tree

11 files changed

+2633
-2045
lines changed

11 files changed

+2633
-2045
lines changed

examples/locales/en-US/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ window.examplesResources = {
597597
"title_iportalWebMap_unicode": "SuperMap iPortal Point Style",
598598
"title_iportalWebMap_unique": "SuperMap iPortal Unique Map",
599599
"title_iportalWebMap_label": "SuperMap iPortal Label Map",
600+
"title_iportalWebMap_mapstudio": "SuperMap iPortal Map Studio",
600601
"title_earthquakeHeatMapLayer": "Earthquake occurrences(2005-2016)(Classic)",
601602
"title_echartsEarthquake": "Earthquake occurrences(2005-2016)",
602603
"title_l_echartsEarthquake": "Earthquake heat map (2001-2014)",

examples/locales/zh-CN/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ window.examplesResources = {
541541
"title_iportalWebMap_unicode": "SuperMap iPortal 点样式",
542542
"title_iportalWebMap_unique": "SuperMap iPortal 单值专题图",
543543
"title_iportalWebMap_label": "SuperMap iPortal 标签专题图",
544+
"title_iportalWebMap_mapstudio": "SuperMap iPortal Map Studio",
544545
"title_earthquakeHeatMapLayer": "2005-2016地震次数(Classic)",
545546
"title_echartsEarthquake": "2005到2016年地震发生情况",
546547
"title_l_echartsEarthquake": "2001年到2014年地震热力图",

examples/mapboxgl/config.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ var exampleConfig = {
7676
version: '11.1.0',
7777
thumbnail: 'query_fgb_features.png',
7878
fileName: '01_mapQueryBySQL_FGB'
79-
},
79+
},
8080
{
8181
name: "图例",
8282
name_en: "Legend",
@@ -327,21 +327,21 @@ var exampleConfig = {
327327
version: '11.1.1',
328328
thumbnail: "terrainSlopeCalculationService.png",
329329
fileName: "04_terrainSlopeCalculationService"
330-
},
330+
},
331331
{
332332
name: "地形坡向计算",
333333
name_en: "terrain aspect calculation",
334334
version: '11.1.1',
335335
thumbnail: "terrainAspectCalculationService.png",
336336
fileName: "04_terrainAspectCalculationService"
337-
},
337+
},
338338
{
339339
name: "填挖方计算",
340340
name_en: "terrain cutfill calculation",
341341
version: '11.1.1',
342342
thumbnail: "terrainCutFillCalculationService.png",
343343
fileName: "04_terrainCutFillCalculationService"
344-
},
344+
},
345345
{
346346
name: "最近距离计算",
347347
name_en: "min distance analysis",
@@ -599,6 +599,13 @@ var exampleConfig = {
599599
version: '9.1.2',
600600
thumbnail: 'iPortalWebmap_unicode.png',
601601
fileName: 'iPortalWebmap_unicode'
602+
},
603+
{
604+
name: 'WebMap 3.0',
605+
name_en: 'WebMap 3.0',
606+
version: '9.1.2',
607+
thumbnail: 'iPortalWebmap_mapstudio.png',
608+
fileName: 'iPortalWebmap_mapstudio'
602609
}
603610
]
604611
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html style=" width: 100%;height: 100%;">
6+
7+
<head>
8+
<meta charset="UTF-8">
9+
<title data-i18n="resources.title_iportalWebMap_range"></title>
10+
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
11+
<script type="text/javascript" include='convert,jsonsql,canvg,geostats,mapbox-gl-enhance'
12+
src="../../dist/mapboxgl/include-mapboxgl.js"></script>
13+
<style>
14+
.dropdown {
15+
position: fixed;
16+
right: 50px;
17+
top: 30px;
18+
}
19+
</style>
20+
</head>
21+
22+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height: 100%">
23+
<div id="map" style="width: 100%;height:100%"></div>
24+
<div class="dropdown">
25+
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown"
26+
aria-haspopup="true" aria-expanded="true">
27+
raster 图层
28+
<span class="caret"></span>
29+
</button>
30+
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu1">
31+
<li map-id="501209431" class="active">
32+
<a href="javascript:void(0)"
33+
title="base/raster/4326 + overlay/vector(fill-extrusion))">3D 拉伸图层
34+
</a>
35+
</li>
36+
<li map-id="1053690230">
37+
<a href="javascript:void(0)"
38+
title="base/raster/3857 + overlay/raster">raster(webp) 图层
39+
</a>
40+
</li>
41+
<li map-id="1414137318">
42+
<a href="javascript:void(0)"
43+
title="base/raster/3857 + overlay/vector">vector 图层
44+
</a>
45+
</li>
46+
</ul>
47+
</div>
48+
<script type="text/javascript">
49+
function getMap(mapId) {
50+
var instance = new mapboxgl.supermap.WebMap(mapId, {
51+
target: 'map',
52+
server: 'https://www.supermapol.com/'
53+
});
54+
instance.on('addlayerssucceeded', function(e) {
55+
mapInstance = e.map;
56+
});
57+
return instance;
58+
}
59+
var selected = 1414137318;
60+
var webMap = getMap(selected);
61+
var mapInstance;
62+
$(document).ready(function () {
63+
var mapId;
64+
$('.dropdown-menu-right').on('click', 'li', function (e) {
65+
mapId = $(this).attr('map-id');
66+
if (!mapInstance || !mapInstance.loaded()) {
67+
alert('地图正在加载中...')
68+
return;
69+
}
70+
if (selected !== mapId) {
71+
mapInstance && mapInstance.remove();
72+
selected = mapId;
73+
$('li').removeClass('active');
74+
$(this).addClass('active');
75+
$('#dropdownMenu1').text($(this).text());
76+
webMap = getMap(selected);
77+
}
78+
});
79+
});
80+
</script>
81+
</body>
47.7 KB
Loading

src/mapboxgl/core/Util.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,44 @@ export const Util = {
235235
return !!fieldName.match(new RegExp(shortName));
236236
}
237237
return false;
238+
},
239+
240+
/**
241+
* @description 墨卡托转经纬度。
242+
* @param {Array} point - 待转换的点。
243+
* @returns {Object} 经纬度坐标。
244+
*/
245+
unproject(point) {
246+
var d = 180 / Math.PI,
247+
r = 6378137,
248+
ts = Math.exp(-point[1] / r),
249+
phi = Math.PI / 2 - 2 * Math.atan(ts);
250+
for (var i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {
251+
con = 1;
252+
dphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;
253+
phi += dphi;
254+
}
255+
return new mapboxgl.LngLat((point[0] * d) / r, phi * d);
256+
},
257+
258+
/**
259+
* @description url 拼接代理或者凭证信息
260+
* @param {string} point - 待转换的 url
261+
* @returns {string} 转换后的 url
262+
*/
263+
transformUrl({ url, server, excludePortalProxyUrl, credentialValue, credentialKey }) {
264+
let mapUrl = url.indexOf('.json') === -1 ? `${url}.json` : url;
265+
let filter = 'getUrlResource.json?url=';
266+
if (excludePortalProxyUrl && server.indexOf(filter) > -1) {
267+
//大屏需求,或者有加上代理的
268+
let urlArray = server.split(filter);
269+
if (urlArray.length > 1) {
270+
mapUrl = urlArray[0] + filter + mapUrl;
271+
}
272+
}
273+
if (credentialValue && credentialKey) {
274+
mapUrl += '?' + credentialKey + '=' + credentialValue;
275+
}
276+
return mapUrl;
238277
}
239278
}

0 commit comments

Comments
 (0)