components_geojson_react.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_componentsGeoJSON_React"></title>
  9. <script type="text/javascript" include="react,jquery" src="../js/include-web.js"></script>
  10. <script include="antd,iclient-mapboxgl-react,mapbox-gl-enhance" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  11. <style>
  12. html,
  13. body {
  14. height: 100%;
  15. margin: 0;
  16. padding: 0;
  17. }
  18. #main {
  19. height: 100%;
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <div id="main"></div>
  25. <script type="text/babel">
  26. var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
  27. var attribution =
  28. "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  29. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  30. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
  31. var SmWebMap = SuperMap.Components.SmWebMap;
  32. var SmGeojsonLayer = SuperMap.Components.SmGeojsonLayer;
  33. var mapOptions = {
  34. container: 'map', // container id
  35. style: {
  36. version: 8,
  37. sources: {
  38. 'raster-tiles': {
  39. attribution: attribution,
  40. type: 'raster',
  41. tiles: [host + '/iserver/services/map-china400/rest/maps/ChinaDark/zxyTileImage.png?z={z}&x={x}&y={y}'],
  42. tileSize: 256
  43. }
  44. },
  45. layers: [
  46. {
  47. id: 'simple-tiles',
  48. type: 'raster',
  49. source: 'raster-tiles',
  50. minzoom: 0,
  51. maxzoom: 22
  52. }
  53. ]
  54. },
  55. center: [120.143, 30.236],
  56. zoom: 3
  57. };
  58. var layerStyle = new SuperMap.Components.commontypes.CircleStyle();
  59. $.get('../data/data671MeteorologicalStations.geojson', function(res) {
  60. var data = JSON.parse(res);
  61. ReactDOM.render(
  62. <SmWebMap mapOptions={mapOptions}>
  63. <SmGeojsonLayer data={data} layerStyle={layerStyle} />
  64. </SmWebMap>,
  65. document.getElementById('main')
  66. );
  67. });
  68. </script>
  69. </body>
  70. </html>