MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / createSpecLayer

Method createSpecLayer

src/openlayers/mapping/WebMap.js:539–659  ·  view source on GitHub ↗

* @private * @function WebMap.prototype.createSpecLayer * @description 创建坐标系为0和-1000的图层 * @param {Object} mapInfo - 地图信息

(mapInfo)

Source from the content-addressed store, hash-verified

537 * @param {Object} mapInfo - 地图信息
538 */
539 createSpecLayer(mapInfo) {
540 let me = this,
541 baseLayerInfo = mapInfo.baseLayer,
542 url = baseLayerInfo.url,
543 baseLayerType = baseLayerInfo.layerType;
544 let extent = [
545 mapInfo.extent.leftBottom.x,
546 mapInfo.extent.leftBottom.y,
547 mapInfo.extent.rightTop.x,
548 mapInfo.extent.rightTop.y
549 ];
550 let proj = new olProj.Projection({
551 extent,
552 units: 'm',
553 code: 'EPSG:0'
554 });
555 olProj.addProjection(proj);
556 let options = {
557 center: mapInfo.center,
558 level: 0
559 };
560 //添加view
561 me.baseProjection = proj;
562 let viewOptions = {
563 center: options.center ? [options.center.x, options.center.y] : [0, 0],
564 zoom: 0,
565 projection: proj
566 };
567 if (['4', '5'].indexOf(Util.getOlVersion()) < 0) {
568 // 兼容 ol 4,5,6
569 viewOptions.multiWorld = true;
570 }
571 let view = new View(viewOptions);
572 me.map.setView(view);
573 if (me.mapParams) {
574 me.mapParams.extent = extent;
575 me.mapParams.projection = mapInfo.projection;
576 }
577 if (url && url.indexOf('?token=') > -1) {
578 //兼容iserver地址有token的情况
579 me.credentialKey = 'token';
580 me.credentialValue = mapInfo.baseLayer.credential = url.split('?token=')[1];
581 url = url.split('?token=')[0];
582 }
583
584 let source;
585 if (baseLayerType === 'TILE') {
586 url = this.handleJSONSuffix(url);
587 FetchRequest.get(me.getRequestUrl(url), null, {
588 withCredentials: me.isCredentail(url)
589 })
590 .then(function (response) {
591 return response.json();
592 })
593 .then(function (result) {
594 baseLayerInfo.originResult = result;
595 let serverType = 'IPORTAL',
596 credential = baseLayerInfo.credential,

Callers 1

getMapInfoSuccessMethod · 0.80

Calls 13

handleJSONSuffixMethod · 0.95
indexOfMethod · 0.80
setViewMethod · 0.80
getRequestUrlMethod · 0.80
isCredentailMethod · 0.80
isAddProxyMethod · 0.80
addSpecToMapMethod · 0.80
createWMSSourceMethod · 0.80
getWMTSScalesMethod · 0.80
createWMTSSourceMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected