Skip to content

Commit 2c2f4a4

Browse files
committed
【feature】 webmap3.0对接; review by songym
1 parent 0285f15 commit 2c2f4a4

File tree

12 files changed

+2776
-2175
lines changed

12 files changed

+2776
-2175
lines changed

examples/locales/en-US/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ window.examplesResources = {
573573
"title_iportalWebMap_unicode": "SuperMap iPortal Point Style",
574574
"title_iportalWebMap_unique": "SuperMap iPortal Unique Map",
575575
"title_iportalWebMap_label": "SuperMap iPortal Label Map",
576+
"title_iportalWebMap_mapstudio": "SuperMap iPortal Map Studio",
576577
"title_earthquakeHeatMapLayer": "Earthquake occurrences(2005-2016)(Classic)",
577578
"title_echartsEarthquake": "Earthquake occurrences(2005-2016)",
578579
"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
@@ -514,6 +514,7 @@ window.examplesResources = {
514514
"title_iportalWebMap_unicode": "SuperMap iPortal 点样式",
515515
"title_iportalWebMap_unique": "SuperMap iPortal 单值专题图",
516516
"title_iportalWebMap_label": "SuperMap iPortal 标签专题图",
517+
"title_iportalWebMap_mapstudio": "SuperMap iPortal Map Studio",
517518
"title_earthquakeHeatMapLayer": "2005-2016地震次数(Classic)",
518519
"title_echartsEarthquake": "2005到2016年地震发生情况",
519520
"title_l_echartsEarthquake": "2001年到2014年地震热力图",

examples/mapboxgl/config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ var exampleConfig = {
413413
fileName: "imageService"
414414
}
415415
]
416-
},
416+
}
417417
}
418418
},
419419
iPortal: {
@@ -460,6 +460,13 @@ var exampleConfig = {
460460
version: '9.1.2',
461461
thumbnail: 'iPortalWebmap_unicode.png',
462462
fileName: 'iPortalWebmap_unicode'
463+
},
464+
{
465+
name: 'WebMap 3.0',
466+
name_en: 'WebMap 3.0',
467+
version: '9.1.2',
468+
thumbnail: 'iPortalWebmap_mapstudio.png',
469+
fileName: 'iPortalWebmap_mapstudio'
463470
}
464471
]
465472
}
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>
Loading

src/mapboxgl/core/Util.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,45 @@ export class Util {
210210
}
211211
return false;
212212
}
213+
214+
/**
215+
* @description 墨卡托转经纬度。
216+
* @param {Array} point - 待转换的点。
217+
* @returns {Object} 经纬度坐标。
218+
*/
219+
static unproject(point) {
220+
var d = 180 / Math.PI,
221+
r = 6378137,
222+
ts = Math.exp(-point[1] / r),
223+
phi = Math.PI / 2 - 2 * Math.atan(ts);
224+
for (var i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {
225+
con = 1;
226+
dphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;
227+
phi += dphi;
228+
}
229+
return new mapboxgl.LngLat((point[0] * d) / r, phi * d);
230+
}
231+
232+
/**
233+
* @description url 拼接代理或者凭证信息
234+
* @param {string} point - 待转换的 url
235+
* @returns {string} 转换后的 url
236+
*/
237+
static transformUrl({ url, server, excludePortalProxyUrl, credentialValue, credentialKey }) {
238+
let mapUrl = url.indexOf('.json') === -1 ? `${url}.json` : url;
239+
let filter = 'getUrlResource.json?url=';
240+
if (excludePortalProxyUrl && server.indexOf(filter) > -1) {
241+
//大屏需求,或者有加上代理的
242+
let urlArray = server.split(filter);
243+
if (urlArray.length > 1) {
244+
mapUrl = urlArray[0] + filter + mapUrl;
245+
}
246+
}
247+
if (credentialValue && credentialKey) {
248+
mapUrl += '?' + credentialKey + '=' + credentialValue;
249+
}
250+
return mapUrl;
251+
}
213252
}
214253

215254
mapboxgl.supermap.Util = Util;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy