01_mapQueryByBounds.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. <title data-i18n="resources.title_mapQueryByBounds"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. </head>
  11. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  12. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  13. <script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  14. <script type="text/javascript">
  15. var map;
  16. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  17. var url = host + "/iserver/services/map-world/rest/maps/World";
  18. var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  19. "with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  20. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
  21. var map = new mapboxgl.Map({
  22. container: 'map',
  23. style: {
  24. "version": 8,
  25. "sources": {
  26. "raster-tiles": {
  27. "attribution": attribution,
  28. "type": "raster",
  29. "tiles": [host + '/iserver/services/maps/rest/maps/World/zxyTileImage.png?prjCoordSys='+encodeURIComponent('{"epsgCode":3857}')+'&z={z}&x={x}&y={y}'],
  30. "tileSize": 256,
  31. },
  32. },
  33. "layers": [{
  34. "id": "simple-tiles",
  35. "type": "raster",
  36. "source": "raster-tiles",
  37. "minzoom": 0,
  38. "maxzoom": 22
  39. }],
  40. },
  41. center: [0, 0],
  42. maxZoom: 18,
  43. zoom: 2
  44. });
  45. map.addControl(new mapboxgl.supermap.LogoControl(), 'bottom-right');
  46. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  47. map.on('load', function () {
  48. query();
  49. });
  50. function query() {
  51. map.addLayer({
  52. 'id': 'polygonLayer',
  53. 'type': 'fill',
  54. 'source': {
  55. 'type': 'geojson',
  56. 'data': {
  57. 'type': 'Feature',
  58. 'geometry': {
  59. 'type': 'Polygon',
  60. 'coordinates': [[[0, 0], [60, 0], [60, 39], [0, 39], [0, 0]]],
  61. }
  62. }
  63. },
  64. 'paint': {
  65. 'fill-outline-color': 'blue',
  66. 'fill-color': 'rgba(0, 0, 255, 0.1)'
  67. }
  68. });
  69. var param = new SuperMap.QueryByBoundsParameters({
  70. queryParams: {name: "Capitals@World.1"},
  71. bounds: new mapboxgl.LngLatBounds([0, 0], [60, 39])
  72. });
  73. queryService = new mapboxgl.supermap.QueryService(url).queryByBounds(param, function (serviceResult) {
  74. var recordsets = serviceResult && serviceResult.result && serviceResult.result.recordsets;
  75. var features = recordsets && recordsets[0] && recordsets[0].features;
  76. map.addLayer({
  77. "id": "points",
  78. "type": "circle",
  79. "paint": {
  80. "circle-radius": 6,
  81. "circle-color": "#007cbf",
  82. "circle-opacity": 0.1,
  83. "circle-stroke-width": 2,
  84. "circle-stroke-color": "#007cbf",
  85. "circle-stroke-opacity": 0.5
  86. },
  87. "source": {
  88. "type": "geojson",
  89. "data": features
  90. }
  91. });
  92. });
  93. }
  94. </script>
  95. </body>
  96. </html>