子域环境搭建及使用


简介

由于浏览器对同一个域名服务的并发请求数量有限制,通过部署多个子域名,加大向iServer发送数据请求的并发量,从而达到提升加载速度的目的。以下以nginx为例搭建环境:

    • 描述:利用nginx客户端,映射不同的端口地址来对iServer进行访问,搭建子域环境,提升性能。
    • 应用场景:充分利用server机器的硬件性能,加大并发量,提升加载速度。

使用

1、nginx客户端部署。

修改nginx.conf文件,如下图所示,修改完成重启nginx,则 http://localhost:8081/iserver、http://localhost:8082/iserver、http://localhost:8083/iserver 都会指向http://localhost:8090/iserver

2、scene.open()打开场景

        var promise = viewer.scene.open('http://{s}/iserver/services/3D-CBD/rest/realspace', undefined, {
            subdomains: ['localhost:8081', 'localhost:8082', 'localhost:8083']//设置子域
        });
        

3、scene.addS3MTilesLayerByScp()添加模型

        var config = {
            subdomainConfig: {
                urlScheme: " http://{s}/iserver/services/3D-CBD/rest/realspace",
                subdomains: ['localhost:8081', 'localhost:8082', 'localhost:8083']//设置子域
            },
            name: "building"
        };

        var promise = viewer.scene.addS3MTilesLayerByScp('http://localhost:8090/iserver/services/3D-CBD/rest/realspace/datas/building/config', config);
        SuperMap3D.when(promise, function (layer) {
            viewer.flyTo(promise);
        })
    

4、地形

        var viewer = new SuperMap3D.Viewer('Container', {
            terrainProvider: new SuperMap3D.SuperMapTerrainProvider({
                url: ' http://{s}/iserver/services/3D-terrain/rest/realspace/datas/dem',
                subdomains: ['localhost:8081', 'localhost:8082', 'localhost:8083']//设置子域
            })
        });
    

5、影像

        var imageLayer = viewer.imageryLayers.addImageryProvider(new SuperMap3D.SuperMapImageryProvider({
            url: ' http://{s}/iserver/services/3D-image/rest/realspace/datas/image',
            subdomains: ['localhost:8081', 'localhost:8082', 'localhost:8083']//设置子域
        }));
        viewer.flyTo(imageLayer);
        

6、mvt

    mvtMap = scene.addVectorTilesMap({
    url: 'http://{s}/services/map-mvt-JingJinDiQuDiTu/restjsr/v1/vectortile/maps/JingJin',
    subdomains: ['localhost:8081', 'localhost:8082', 'localhost:8083']//设置子域
    canvasWidth: 512,
    name: 'testMVT',
    viewer: viewer
});

                    

加载效果:从网络请求里看是否有不同端口的请求,比如'localhost:8081', 'localhost:8082', 'localhost:8083'

版权所有 © 2000-2024 北京超图软件股份有限公司 京ICP备11032883号-8 京公网安备11010502008721 甲测资字11002074