02_getGridCellInfos.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html lang="en">
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_getGridCellInfos"></title>
  9. <script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  10. </head>
  11. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  12. <h5 data-i18n="resources.text_clickGridCellToQuery"
  13. style=" position: absolute; display: block; margin-left: 60px; z-index: 100;"></h5>
  14. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  15. <script type="text/javascript" src="../js/include-web.js"></script>
  16. <script>
  17. var map,
  18. baseUrl = (window.isLocal ? window.server : "https://iserver.supermap.io") + "/iserver/services/map-world/rest/maps/World Map/zxyTileImage.png?z={z}&x={x}&y={y}",
  19. dataUrl = (window.isLocal ? window.server : "https://iserver.supermap.io") + "/iserver/services/data-world/rest/data";
  20. var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  21. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  22. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
  23. map = new mapboxgl.Map({
  24. container: 'map',
  25. style: {
  26. "version": 8,
  27. "sources": {
  28. "raster-tiles": {
  29. "attribution": attribution,
  30. "type": "raster",
  31. "tiles": [baseUrl],
  32. "tileSize": 256
  33. }
  34. },
  35. "layers": [{
  36. "id": "simple-tiles",
  37. "type": "raster",
  38. "source": "raster-tiles",
  39. }]
  40. },
  41. center: [0, 0],
  42. zoom: 3
  43. });
  44. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  45. map.addControl(new mapboxgl.supermap.LogoControl(), 'bottom-right');
  46. map.on("click", function (evt) {
  47. var x = evt.lngLat.lng;
  48. var y = evt.lngLat.lat;
  49. if (x < -180.0 || x > 180.0 || y < -90 || y > 90) {
  50. return;
  51. }
  52. var getGridCellInfosParam = new SuperMap.GetGridCellInfosParameters({
  53. dataSourceName: "World",
  54. datasetName: "WorldEarth",
  55. X: x,
  56. Y: y
  57. });
  58. new mapboxgl.supermap.GridCellInfosService(dataUrl).getGridCellInfos(getGridCellInfosParam, function (serviceResult) {
  59. if (!serviceResult.result) {
  60. return;
  61. }
  62. var result = serviceResult.result;
  63. var innerHTML = resources.text_gridQueryResult + "<br>" + "column: " + result.column + "<br>";
  64. innerHTML += "row: " + result.row + "<br>";
  65. innerHTML += "value: " + result.value + "<br>";
  66. new mapboxgl.Popup().setLngLat([x, y]).setHTML(innerHTML).addTo(map);
  67. });
  68. });
  69. </script>
  70. </body>
  71. </html>