|
| 1 | +<!--******************************************************************** |
| 2 | +* Copyright© 2000 - 2023 SuperMap Software Co.Ltd. All rights reserved. |
| 3 | +*********************************************************************--> |
| 4 | +<!DOCTYPE html> |
| 5 | +<html> |
| 6 | + <head> |
| 7 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 8 | + <title data-i18n="resources.title_videoLayer"></title> |
| 9 | + <style type="text/css"> |
| 10 | + body { |
| 11 | + margin: 0; |
| 12 | + padding: 0; |
| 13 | + } |
| 14 | + |
| 15 | + #map { |
| 16 | + position: absolute; |
| 17 | + top: 0; |
| 18 | + bottom: 0; |
| 19 | + width: 100%; |
| 20 | + } |
| 21 | + </style> |
| 22 | + </head> |
| 23 | + <body> |
| 24 | + <div id="map"></div> |
| 25 | + <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script> |
| 26 | + <script |
| 27 | + type="text/javascript" |
| 28 | + include="mapbox-gl-enhance,proj4,turf,opencv" |
| 29 | + src="../../dist/mapboxgl/include-mapboxgl.js" |
| 30 | + ></script> |
| 31 | + <script type="text/javascript"> |
| 32 | + var host = window.isLocal ? window.server : 'https://iserver.supermap.io'; |
| 33 | + var map, |
| 34 | + videoLayer, |
| 35 | + url = host + '/iserver/services/map-world/rest/maps/World'; |
| 36 | + var attribution = |
| 37 | + "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" + |
| 38 | + " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" + |
| 39 | + " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> "; |
| 40 | + var dataUrl = 'http://172.16.13.234:8090/iserver/services/data-test0104/rest/data'; |
| 41 | + var datasourceName = 'NewDatasource'; |
| 42 | + var datasetName = 'aaa'; |
| 43 | + var map = new mapboxgl.Map({ |
| 44 | + container: 'map', |
| 45 | + renderWorldCopies: false, |
| 46 | + style: { |
| 47 | + version: 8, |
| 48 | + sources: { |
| 49 | + 'raster-tiles': { |
| 50 | + attribution: attribution, |
| 51 | + type: 'raster', |
| 52 | + tiles: [url + '/zxyTileImage.png?z={z}&x={x}&y={y}'], |
| 53 | + tileSize: 256 |
| 54 | + } |
| 55 | + }, |
| 56 | + layers: [ |
| 57 | + { |
| 58 | + id: 'simple-tiles', |
| 59 | + type: 'raster', |
| 60 | + source: 'raster-tiles', |
| 61 | + minzoom: 0, |
| 62 | + maxzoom: 9 |
| 63 | + } |
| 64 | + ] |
| 65 | + }, |
| 66 | + center: [116.14734767029731, 28.320871401184714], |
| 67 | + zoom: 16 |
| 68 | + }); |
| 69 | + map.addControl(new mapboxgl.NavigationControl(), 'top-left'); |
| 70 | + map.addControl(new mapboxgl.supermap.LogoControl({ link: 'https://iclient.supermap.io' }), 'bottom-right'); |
| 71 | + function query() { |
| 72 | + var sqlParam = new mapboxgl.supermap.GetFeaturesBySQLParameters({ |
| 73 | + queryParameter: { |
| 74 | + name: datasetName + '@' + datasourceName, |
| 75 | + attributeFilter: 'SMID > 0' |
| 76 | + }, |
| 77 | + datasetNames: [datasourceName + ':' + datasetName] |
| 78 | + }); |
| 79 | + |
| 80 | + new mapboxgl.supermap.FeatureService(dataUrl).getFeaturesBySQL(boundsParam).then(function (serviceResult) { |
| 81 | + let coordinates = []; |
| 82 | + turf.featureEach(serviceResult.result.features, function (currentFeature, featureIndex) { |
| 83 | + currentFeature.geometry.coordinates[0][0].forEach((coord) => { |
| 84 | + const res = proj4('EPSG:3857', 'EPSG:4326', coord); |
| 85 | + coordinates.push(res); |
| 86 | + }); |
| 87 | + }); |
| 88 | + let address = serviceResult.result.features.features[0].properties.address; |
| 89 | + videoLayer = new mapboxgl.supermap.VideoLayer({ |
| 90 | + url: address, |
| 91 | + extent: [coordinates[3], coordinates[2], coordinates[1], coordinates[0]] |
| 92 | + }); |
| 93 | + map.addLayer(videoLayer); |
| 94 | + }); |
| 95 | + } |
| 96 | + map.on('load', function () { |
| 97 | + query(); |
| 98 | + }); |
| 99 | + </script> |
| 100 | + </body> |
| 101 | +</html> |
0 commit comments