l_popup_vue.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_componentsPopup_Vue"></title>
  9. <script type="text/javascript" include="vue" src="../js/include-web.js"></script>
  10. <script include="iclient-leaflet-vue" src="../../dist/leaflet/include-leaflet.js"></script>
  11. <style>
  12. #main {
  13. position: relative;
  14. margin: 0 auto;
  15. width: 100%;
  16. height: 100%;
  17. }
  18. .message {
  19. position: absolute;
  20. left: 10px;
  21. top: 10px;
  22. }
  23. </style>
  24. </head>
  25. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  26. <div id="main">
  27. <sm-web-map server-url="https://iportal.supermap.io/iportal" map-id="1329428269" @click="mapClick">
  28. <!-- 弹窗组件 -->
  29. <sm-popup>
  30. <sm-table :columns="columns" :data-source="data" :pagination="false" />
  31. </sm-popup>
  32. </sm-web-map>
  33. </div>
  34. <script>
  35. new Vue({
  36. el: '#main',
  37. data() {
  38. return {
  39. // table的props
  40. columns: [
  41. { key: 1, title: '经度', dataIndex: 'lng' },
  42. { key: 2, title: '纬度', dataIndex: 'lat' }
  43. ],
  44. data: []
  45. };
  46. },
  47. mounted(){
  48. this.$message.info(resources.msg_clickToPopup);
  49. },
  50. methods: {
  51. mapClick(e) {
  52. let latLng = e.map.layerPointToLatLng(e.mapboxEvent.layerPoint);
  53. this.data = [{ key: 1, lng: latLng.lng.toFixed(2), lat: latLng.lat.toFixed(2) }];
  54. }
  55. }
  56. });
  57. </script>
  58. </body>
  59. </html>