ArcGIS JS 3.x加载geoserver发布的3857坐标系的矢量切片服务

通过geoserver加载shp数据发布成矢量切片在线服务,调用方式参考该资料:

全部代码:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
    <title>矢量切片</title>
    <link rel="stylesheet" href="http://localhost/arcgis/library/3.27/3.27/esri/css/esri.css">
    <style>
        html, body, #map {
            height: 100%;
            margin: 0;
            padding: 0;
        }

        body {
            background-color: #FFF;
            overflow: hidden;
            font-family: "Trebuchet MS";
        }
    </style>
    <script src="http://localhost/arcgis/library/3.27/3.27/init.js"></script>
    <script src="js/jquery.js"></script>
    <script>

        var map;
        require([
            "esri/map",
            "esri/layers/ArcGISTiledMapServiceLayer",
            "esri/layers/ArcGISDynamicMapServiceLayer",
            "esri/layers/VectorTileLayer",
            "esri/layers/GraphicsLayer",
            "esri/symbols/SimpleLineSymbol",
            "esri/geometry/projection",
            "esri/geometry/Point",
            "esri/SpatialReference",
            "dojo/on",
            "dojo/dom",
            "dojo/domReady!"],
            function (Map,
                ArcGISTiledMapServiceLayer,
                ArcGISDynamicMapServiceLayer,
                VectorTileLayer,
                GraphicsLayer,
                SimpleLineSymbol,
                projection,
                Point,
                SpatialReference,
                on,
                dom
            ) {
                map = new Map("map", {
                    center: [101.78, 36.62],
                    zoom: 12,
                    logo: false
                });
                var DXT = new ArcGISTiledMapServiceLayer("http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer", { id: "DXT" });
                map.addLayer(DXT);
                var style = {       
                    "version": 8,
                    "sources": {
                        "osm": {     
                            "type": "vector",
                            "tiles": ["http://localhost:8080/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=map:PIPESECTIONMPA&STYLE=&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}"],  
                               
                        }
                    },
                    "layers": [
                        {
                            id: "sampleline",
                            type: "line",
                            source: "osm",
                            "source-layer": "PIPESECTIONMPA",
                            paint: {
                                "line-color": "#3031ff"
                            }
                        }
                    ],
                    "id": "test"

                };
                var tileLyr = new VectorTileLayer(style);
                map.addLayer(tileLyr);
            });
    </script>
</head>
<body>
    <div id="map"></div>
</body>
</html>

效果图:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值