12_pulse.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_pulse"></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" include="leaflet-icon-pulse" src="../../dist/leaflet/include-leaflet.js"></script>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, resultLayer, markers = [],
  17. dataUrl = host + "/iserver/services/data-DynamicData/rest/data",
  18. url = host + "/iserver/services/map-china400/rest/maps/China",
  19. pulseIcon = L.icon.pulse({
  20. iconSize: [12, 12],
  21. color: '#2f8'
  22. });
  23. map = L.map('map', {
  24. preferCanvas: true,
  25. center: [32, 104],
  26. maxZoom: 18,
  27. zoom: 4
  28. });
  29. L.supermap.tiledMapLayer(url).addTo(map);
  30. loadPulse();
  31. function loadPulse() {
  32. var point1 = L.CRS.EPSG3857.project(L.latLng(22, 96));
  33. var point2 = L.CRS.EPSG3857.project(L.latLng(42, 124));
  34. var bounds = L.latLngBounds(L.latLng(point1.y, point1.x), L.latLng(point2.y, point2.x));
  35. var boundsParam = new SuperMap.GetFeaturesByBoundsParameters({
  36. datasetNames: ["DynamicData:Point"],
  37. bounds: bounds
  38. });
  39. L.supermap
  40. .featureService(dataUrl)
  41. .getFeaturesByBounds(boundsParam, function (serviceResult) {
  42. createLayers(serviceResult.result.features);
  43. });
  44. }
  45. function createLayers(result) {
  46. if (!result || !result.features || result.features.length < 1) {
  47. return;
  48. }
  49. result.features.map(function (feature) {
  50. var latLng = L.CRS.EPSG3857.unproject(L.point(feature.geometry.coordinates));
  51. markers.push(L.marker(latLng, {icon: pulseIcon}));
  52. });
  53. resultLayer = L.featureGroup(markers).addTo(map);
  54. }
  55. </script>
  56. </body>
  57. </html>