/examples/mapboxgl/01_mapQueryBySQL.html

https://github.com/SuperMap/iClient-JavaScript · HTML · 83 lines · 76 code · 4 blank · 3 comment · 0 complexity · b1658f418194dd89c04b3b76c3ebb254 MD5 · raw file

  1. <!--********************************************************************
  2. * Copyright© 2000 - 2020 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_mapQueryBySQL"></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 host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var url = host + "/iserver/services/map-world/rest/maps/World";
  17. var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  18. "with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  19. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
  20. var map = new mapboxgl.Map({
  21. container: 'map',
  22. style: {
  23. "version": 8,
  24. "sources": {
  25. "raster-tiles": {
  26. "attribution": attribution,
  27. "type": "raster",
  28. "tiles": [host + '/iserver/services/maps/rest/maps/World/zxyTileImage.png?prjCoordSys='+encodeURIComponent('{"epsgCode":3857}')+'&z={z}&x={x}&y={y}'],
  29. "tileSize": 256,
  30. },
  31. },
  32. "layers": [{
  33. "id": "simple-tiles",
  34. "type": "raster",
  35. "source": "raster-tiles",
  36. "minzoom": 0,
  37. "maxzoom": 22
  38. }],
  39. },
  40. center: [0, 0],
  41. maxZoom: 18,
  42. zoom: 2
  43. });
  44. map.addControl(new mapboxgl.supermap.LogoControl(), 'bottom-right');
  45. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  46. map.on('load', function () {
  47. query();
  48. });
  49. function query() {
  50. var param = new SuperMap.QueryBySQLParameters({
  51. queryParams: {
  52. name: "Capitals@World.1",
  53. attributeFilter: "SMID < 10"
  54. }
  55. });
  56. queryService = new mapboxgl.supermap.QueryService(url).queryBySQL(param, function (serviceResult) {
  57. var recordsets = serviceResult && serviceResult.result && serviceResult.result.recordsets;
  58. var features = recordsets && recordsets[0] && recordsets[0].features;
  59. map.addLayer({
  60. "id": "points",
  61. "type": "circle",
  62. "paint": {
  63. "circle-radius": 6,
  64. "circle-color": "#007cbf",
  65. "circle-opacity":0.1,
  66. "circle-stroke-width":2,
  67. "circle-stroke-color":"#007cbf",
  68. "circle-stroke-opacity":0.5
  69. },
  70. "source": {
  71. "type": "geojson",
  72. "data": features
  73. }
  74. });
  75. });
  76. }
  77. </script>
  78. </body>
  79. </html>