arcgis js 3.x和arcigs js 4.x加载postgis计算得矢量切片

主要区别 arcigs js 4.20(最新版本)支持match stop等函数(用这些函数可以进行分级渲染) ,3.x不支持这些函数,另外我试了下4.16版本也不支持,应该是最新得版本才支持得。

另外,注意的是,3.x版本构建矢量切片图层实例得时候传入得是一个参数,而4传入得是个对象。

1.arcgis js 3.37加载矢量切片

<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <title>Add a vector tile source</title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <link href='http://localhost/arcgis_js_api_337/library/3.37/3.37/esri/css/esri.css' rel='stylesheet' />
    <script src='http://localhost/arcgis_js_api_337/library/3.37/3.37/init.js'></script>
 
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>
<body>
    <div id='map'></div>
    <script>
     
    require(["esri/map",
            "esri/layers/VectorTileLayer",
        ], function (
            Map, VectorTileLayer) {
            
           
            var map = new Map("map", {
                logo: false,
                center: [118.5151588, 31.6648887],
                zoom: 16,
                showAttribution: false,
                basemap: "streets-vector",
                maxZoom: 18
            });
            var style = {
                "version": 8,
                "sources": {
                    "osm": {
                        "tiles": ['http://localhost/VectorTile/tiles.ashx?m=getVectorTile&z={z}&x={x}&y={y}'],
                        "type": "vector"
                    }
                },
                "layers": [
                    {
                        id: "gx",
                        type: "line",
                        source: "osm",
                        "source-layer": "lines",
                        minzoom: 0,
                        maxzoom: 24,
                        "paint": {
                            'line-color': '#DB0B00',
                            'line-width':2
                        }
                    }
                ],
                "id": "test"
            };
          
            var tileLyr = new VectorTileLayer(style);
            map.addLayer(tileLyr);             
        });
    </script>

</body>
</html>

2.arcgis js 4.20加载矢量切片

<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <title>Add a vector tile source</title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <script src='http://localhost/arcgis_js_api_420/4.20/init.js'></script>
    <link href='http://localhost/arcgis_js_api_420/4.20/esri/css/main.css' rel='stylesheet' /> 
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>
<body>
    <div id='map'></div>
    <script>
        require(["esri/Map",
            "esri/views/MapView",
            "esri/layers/VectorTileLayer",
        ], function (
            Map, MapView, VectorTileLayer) {
            var style = {
                "version": 8,
                "sources": {
                    "osm": {
                        "tiles": ['http://localhost/VectorTile/tiles.ashx?m=getVectorTile&z={z}&x={x}&y={y}'],
                        "type": "vector"
                    }
                },
                "layers": [
                    {
                        id: "gx",
                        type: "line",
                        source: "osm",
                        "source-layer": "lines",
                        minzoom: 0,
                        maxzoom: 24,
                        "paint": {
                            'line-color': ['match', ['get', 'fs_name'], 'A', '#DB0B00', 'B', '#FE9003', 'C', '#FCFC82', 'D', '#59EB04', 'E', '#595CCF', '#FFF5EE'],
                            'line-width':2
                        }
                    }
                ],
                "id": "test"
            };
            var map = new Map();
            var view = new MapView({
                container: "map",
                map: map,
                center: [118.5151588, 31.6648887],
                zoom: 16,
            });
            var tileLyr = new VectorTileLayer({
                style: style
            });
            map.add(tileLyr);   
        });
    </script>

</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值