widget.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="compass">
  3. <div class="turn-left" title="顺时针转动" @click="mapRotating(0)"></div>
  4. <div class="compass-middle" :style="{transform:'rotate('+rRotating+'deg)',transition:'transform 0.6s linear'}"></div>
  5. <div class="turn-right" title="逆时针转动" @click="mapRotating(1)"></div>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. props: ["map"],
  11. data() {
  12. return {
  13. rRotating: 0
  14. }
  15. },
  16. methods: {
  17. mapRotating(type) {
  18. if (type == 0) {
  19. this.rRotating -= 90
  20. this.map.getView().animate({
  21. rotation: this.map.getView().getRotation() - 90*(Math.PI/180),
  22. duration: 600
  23. });
  24. } else {
  25. this.rRotating += 90
  26. this.map.getView().animate({
  27. rotation: this.map.getView().getRotation() + 90*(Math.PI/180),
  28. duration: 600
  29. });
  30. }
  31. }
  32. }
  33. }
  34. </script>
  35. <style lang="scss" scoped>
  36. .compass {
  37. margin-bottom:5px ;
  38. position: relative;
  39. float: left;
  40. height: 54px;
  41. width: 54px;
  42. line-height: 54px;
  43. background: url('../../../../../assets/images/bgcicle.png') no-repeat;
  44. background-size: 54px 54px;
  45. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
  46. background-color: rgb(255, 255, 255);
  47. border-radius: 2px;
  48. padding: 0 !important;
  49. cursor: pointer;
  50. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
  51. left: -13px;
  52. border-radius: 32px;
  53. .turn-left {
  54. display: inline-block;
  55. vertical-align: middle;
  56. width: 7px;
  57. margin-left: 3px;
  58. margin-right: 2px;
  59. height: 28px;
  60. background: url('../../../../../assets/images/turn.png') no-repeat;
  61. background-size: 7px 28px;
  62. cursor: pointer;
  63. // margin-top: 15px;
  64. &:hover {
  65. background: url('../../../../../assets/images/turnhover.png') no-repeat;
  66. background-size: 8px 28px;
  67. }
  68. }
  69. .compass-middle {
  70. display: inline-block;
  71. vertical-align: middle;
  72. width: 12px;
  73. margin: 0 5px;
  74. height: 38px;
  75. // margin-top: 13px;
  76. background: url('../../../../../assets/images/compass.png') no-repeat;
  77. background-size: 12px 38px;
  78. }
  79. .turn-right {
  80. display: inline-block;
  81. vertical-align: middle;
  82. width: 7px;
  83. // margin-right: 3px;
  84. // margin-left: 2px;
  85. height: 28px;
  86. background: url('../../../../../assets/images/turn.png') no-repeat;
  87. background-size: 7px 28px;
  88. transform: scaleX(-1);
  89. // margin-top: 15px;
  90. cursor: pointer;
  91. &:hover {
  92. background: url('../../../../../assets/images/turnhover.png') no-repeat;
  93. background-size: 8px 28px;
  94. }
  95. }
  96. }
  97. </style>