overlay_vectorDataEvent.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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_vectorDataEvent"></title>
  9. <style type="text/css">
  10. body {
  11. margin: 0;
  12. overflow: hidden;
  13. background: #fff;
  14. width: 100%;
  15. height: 100%
  16. }
  17. #map {
  18. position: absolute;
  19. width: 100%;
  20. height: 100%;
  21. }
  22. #toolbar {
  23. position: absolute;
  24. top: 50px;
  25. right: 10px;
  26. text-align: center;
  27. z-index: 100;
  28. border-radius: 4px;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div id="toolbar" class="panel panel-primary">
  34. <div class='panel-heading'>
  35. <h5 class='panel-title text-center' data-i18n="resources.title_vectorDataEvent"></h5></div>
  36. <div class='panel-body content'>
  37. <input type="button" class="btn btn-default" data-i18n="[value]resources.text_input_value_addData" onclick="addData()"/>
  38. </div>
  39. </div>
  40. <div id="map"></div>
  41. <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
  42. <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
  43. <script>
  44. var map, layer, vectorlayer, pointFeature,
  45. host = window.isLocal ? window.server : "https://iserver.supermap.io",
  46. url = host + "/iserver/services/map-world/rest/maps/World";
  47. init();
  48. function init() {
  49. map = new SuperMap.Map("map", {
  50. controls: [
  51. new SuperMap.Control.Zoom(),
  52. new SuperMap.Control.Navigation(),
  53. ]
  54. });
  55. map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
  56. layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, null, {maxResolution: "auto"});
  57. layer.events.on({"layerInitialized": addLayer});
  58. vectorlayer = new SuperMap.Layer.Vector("vectorLayer");
  59. var callbacks = {
  60. click: function (currentFeature) {
  61. closeInfoWin();
  62. var popup = new SuperMap.Popup.FramedCloud("popwin",
  63. new SuperMap.LonLat(0, 0),
  64. null,
  65. resources.text_mouseClickEventLayer,
  66. null,
  67. true);
  68. infowin = popup;
  69. map.addPopup(popup);
  70. }
  71. };
  72. var selectFeature = new SuperMap.Control.SelectFeature(vectorlayer,
  73. {
  74. callbacks: callbacks
  75. });
  76. map.addControl(selectFeature);
  77. selectFeature.activate();
  78. }
  79. function addLayer() {
  80. map.addLayers([layer, vectorlayer]);
  81. //显示地图范围
  82. map.setCenter(new SuperMap.LonLat(0, 0), 0);
  83. }
  84. var infowin = null;
  85. function closeInfoWin() {
  86. if (infowin) {
  87. try {
  88. infowin.hide();
  89. infowin.destroy();
  90. }
  91. catch (e) {
  92. }
  93. }
  94. }
  95. function addData() {
  96. vectorlayer.removeAllFeatures();
  97. var point = new SuperMap.Geometry.Point(0, 0);
  98. pointFeature = new SuperMap.Feature.Vector(point);
  99. pointFeature.style = {
  100. fillColor: "red",
  101. strokeColor: "yellow",
  102. pointRadius: 7
  103. };
  104. vectorlayer.addFeatures(pointFeature);
  105. }
  106. </script>
  107. </body>
  108. </html>