原文链接及内容

这个例子展示了如何使用动态的ArcGIS REST MapService。此数据源类型支持地图和图像服务,用于动态ArcGIS服务。
main.js
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| import Map from 'ol/Map.js'; import View from 'ol/View.js'; import {ImageArcGISRest, OSM} from 'ol/source.js'; import {Image as ImageLayer, Tile as TileLayer} from 'ol/layer.js';
const url = 'https://sampleserver6.arcgisonline.com/ArcGIS/rest/services/' + 'USA/MapServer';
const layers = [ new TileLayer({ source: new OSM(), }), new ImageLayer({ source: new ImageArcGISRest({ ratio: 1, params: {}, url: url, }), }), ]; const map = new Map({ layers: layers, target: 'map', view: new View({ center: [-10997148, 4569099], zoom: 4, }), });
|
界面布局文件index.html
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Image ArcGIS MapServer</title> <link rel="stylesheet" href="node_modules/ol/ol.css"> <style> .map { width: 100%; height: 400px; } </style> </head> <body> <div id="map" class="map"></div> <script src="https://cdn.jsdelivr.net/npm/elm-pep@1.0.6/dist/elm-pep.js"></script> <script type="module" src="main.js"></script> </body> </html>
|