01_tiledMapLayer_4610.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="utf-8" />
  8. <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
  9. <title data-i18n="resources.title_tiledMapLayer_Xian80"></title>
  10. <script type="text/javascript" src="../js/include-web.js"></script>
  11. <script
  12. type="text/javascript"
  13. include="mapbox-gl-enhance"
  14. src="../../dist/mapboxgl/include-mapboxgl.js"
  15. ></script>
  16. <style>
  17. body {
  18. margin: 0;
  19. padding: 0;
  20. }
  21. #map {
  22. position: absolute;
  23. top: 0;
  24. bottom: 0;
  25. width: 100%;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div id="map"></div>
  31. <script type="text/javascript">
  32. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  33. var url = host + '/iserver/services/map-china400/rest/maps/China_4610';
  34. var map = new mapboxgl.Map({
  35. container: 'map', // container id
  36. style: {
  37. version: 8,
  38. sources: {
  39. 'raster-tiles': {
  40. type: 'raster',
  41. tileSize: 256,
  42. //xyz形式,原生支持
  43. //"tiles": ['https://t0.tianditu.gov.cn/DataServer?T=vec_c&x={x}&y={y}&l={z}'],
  44. //iserver image资源模板;扩展支持
  45. //"tiles": ['https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China_4610/image.png?viewBounds={viewBounds}&width={width}&height={height}'],
  46. //iserver tileimage资源模板;扩展支持
  47. //"tiles": ['https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China_4610/tileimage.png?scale={scale}&x={x}&y={y}&width={width}&height={height}&origin={"x":-180,"y":90}'],
  48. //推荐; iserver tileimage资源;扩展支持
  49. //参数列表:
  50. //地图服务地址(到地图名)必填 ;
  51. //rasterSource为"iserver";必填;
  52. //transparent:可选,默认为true;
  53. //cacheEnabled: 是否使用缓存,默认为true;
  54. //redirect: 如果为 true,则将请求重定向到瓦片的真实地址;如果为 false,则响应体中是瓦片的字节流,默认为false;
  55. //layersID:要显示的图层id字符串;
  56. //tileversion: 切片版本名称,cacheEnabled 为 true 时有效;
  57. //rasterfunction: 栅格分析参数,类型为SuperMap.NDVIParameter或SuperMap.HillshadeParameter;
  58. //format:瓦片格式,默认为'png';
  59. tiles: [url],
  60. rasterSource: 'iserver'
  61. }
  62. },
  63. layers: [
  64. {
  65. id: 'simple-tiles',
  66. type: 'raster',
  67. source: 'raster-tiles',
  68. minzoom: 0,
  69. maxzoom: 22
  70. }
  71. ]
  72. },
  73. crs: 'EPSG:4610',
  74. center: [101.74721254733845, 32.5665352689922],
  75. zoom: 3
  76. });
  77. map.on('load', function() {
  78. //从 iServer 查询
  79. var param = new SuperMap.QueryBySQLParameters({
  80. queryParams: {
  81. name: 'China_Province_pl@China',
  82. attributeFilter: 'SMID =14'
  83. }
  84. });
  85. new mapboxgl.supermap.QueryService(url).queryBySQL(param, function(serviceResult) {
  86. map.addSource('queryDatas', {
  87. type: 'geojson',
  88. data: serviceResult.result.recordsets[0].features
  89. });
  90. map.addLayer({
  91. id: 'queryDatas',
  92. type: 'fill',
  93. source: 'queryDatas',
  94. paint: {
  95. 'fill-color': '#008080',
  96. 'fill-opacity': 0.4
  97. },
  98. filter: ['==', '$type', 'Polygon']
  99. });
  100. });
  101. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  102. });
  103. </script>
  104. </body>
  105. </html>