Map.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="maps" @click="changeMap" :style="MapStyle">
  3. <el-amap :zoom="Option.zoom" :center="Option.position">
  4. <!-- 当前坐标 -->
  5. <el-amap-circle-marker
  6. :center="Option.position"
  7. :radius="5"
  8. fillColor="#3E86F1"
  9. :strokeWeight="0"
  10. />
  11. </el-amap>
  12. </div>
  13. </template>
  14. <script>
  15. import Vue from "vue";
  16. import VueAMap from "vue-amap";
  17. VueAMap.initAMapApiLoader({
  18. key: "99f684b9a7773a40ca224894816f7c68",
  19. plugin: [
  20. "AMap.Autocomplete",
  21. "AMap.Geolocation",
  22. "Geocoder",
  23. "AMap.OverView",
  24. ],
  25. v: "1.4.15",
  26. });
  27. Vue.use(VueAMap);
  28. export default {
  29. props: {
  30. Option: {
  31. type: Object,
  32. defualt: () => {
  33. return {
  34. position: [104.056608, 30.695942],
  35. zoom: 5,
  36. };
  37. },
  38. },
  39. },
  40. data () {
  41. return {
  42. num: 0,
  43. MapStyle: {
  44. top: "5px",
  45. left: "5px",
  46. width: "50px",
  47. height: "50px",
  48. },
  49. }
  50. },
  51. methods: {
  52. // 切换地图
  53. changeMap() {
  54. this.num++;
  55. if (this.num % 2) {
  56. this.MapStyle = {
  57. top: "20px",
  58. left: "50%",
  59. transform: "translateX(-50%)",
  60. width: "400px",
  61. height: "200px",
  62. borderRadius: "10px",
  63. };
  64. } else {
  65. this.MapStyle = {
  66. top: "5px",
  67. left: "5px",
  68. width: "50px",
  69. height: "50px",
  70. borderRadius: "50%",
  71. };
  72. }
  73. },
  74. },
  75. };
  76. </script>
  77. <style scoped>
  78. .maps {
  79. position: fixed;
  80. overflow: hidden;
  81. z-index: 99;
  82. top: 5px;
  83. left: 5px;
  84. width: 50px;
  85. height: 50px;
  86. border-radius: 50%;
  87. }
  88. </style>