123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_bufferAnalystService"></title>
- <script type="text/javascript" src="../js/include-web.js"></script>
- <script type="text/javascript" src="../../dist/ol/include-ol.js"></script>
- </head>
- <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
- <div id="map" style="width: 100%;height:100%"></div>
- <script type="text/javascript">
- var map, roadLine,
- baseUrl = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/map-changchun/rest/maps/长春市区图",
- serviceUrl = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/spatialanalyst-changchun/restjsr/spatialanalyst";
- var extent = [48.4, -7668.25, 8958.85, -55.58];
- var projection = new ol.proj.Projection({
- code:'',
- extent: extent,
- units: 'm'
- });
- new ol.supermap.MapService(baseUrl).getMapInfo(function (serviceResult) {
- var mapJSONObj = serviceResult.result;
- map = new ol.Map({
- target: 'map',
- controls: ol.control.defaults({attributionOptions: {collapsed: false}})
- .extend([new ol.supermap.control.Logo()]),
- view: new ol.View({
- center: [5105, -3375],
- zoom: 6,
- projection: projection,
- multiWorld: true
- })
- });
- var layer = new ol.layer.Tile({
- source: new ol.source.TileSuperMapRest(ol.source.TileSuperMapRest.optionsFromMapJSON(baseUrl, mapJSONObj))
- });
- map.addLayer(layer);
- roadLine = new ol.geom.LineString([
- [5305.19551436013, -3376.9669111768926],
- [5075.3145648369318, -3378.0037556404409],
- [5006.0235999418364, -3358.8890067038628],
- [4960.9674060199022, -3349.3316322355736],
- [4933.319287022352, -3337.3849141502124]
- ]);
- var vectorSource = new ol.source.Vector({
- features: [new ol.Feature(roadLine)]
- });
- var vectorLayer = new ol.layer.Vector({
- source: vectorSource,
- style: new ol.style.Style({
- stroke: new ol.style.Stroke({
- color: 'blue',
- width: 3
- }),
- fill: new ol.style.Fill({
- color: 'rgba(0, 0, 255, 0.1)'
- })
- })
- });
- map.addLayer(vectorLayer);
- bufferAnalystProcess();
- });
- function bufferAnalystProcess() {
- var dsBufferAnalystParameters = new SuperMap.DatasetBufferAnalystParameters({
- dataset: "RoadLine2@Changchun",
- filterQueryParameter: new SuperMap.FilterParameter({
- attributeFilter: "NAME='团结路'"
- }),
- bufferSetting: new SuperMap.BufferSetting({
- endType: SuperMap.BufferEndType.ROUND,
- leftDistance: {value: 10},
- rightDistance: {value: 10},
- semicircleLineSegment: 10
- })
- });
- new ol.supermap.SpatialAnalystService(serviceUrl).bufferAnalysis(dsBufferAnalystParameters, function (serviceResult) {
- var vectorSource = new ol.source.Vector({
- features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.recordset.features)
- });
- var resultLayer = new ol.layer.Vector({
- source: vectorSource,
- style: new ol.style.Style({
- stroke: new ol.style.Stroke({
- color: 'red',
- width: 1
- }),
- fill: new ol.style.Fill({
- color: 'rgba(255, 0, 0, 0.1)'
- })
- })
- });
- map.addLayer(resultLayer);
- });
- }
- </script>
- </body>
- </html>
|