Structures.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <LayoutContainer>
  3. <v-responsive :aspect-ratio="1" width="100%">
  4. <no-ssr>
  5. <l-map
  6. id="map"
  7. :zoom="zoom"
  8. :center="center"
  9. :bounds="bounds"
  10. :options="{scrollWheelZoom: false, zoomSnap: 0.25}"
  11. @ready="$emit('ready', $event, field)"
  12. @update="$emit('update', $event, field)"
  13. >
  14. <l-tile-layer
  15. url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"
  16. attribution="&copy; <a href='http://osm.org/copyright'>OpenStreetMap</a> contributors"
  17. />
  18. <!-- <l-marker :lat-lng="[55.9464418,8.1277591]" />-->
  19. </l-map>
  20. </no-ssr>
  21. </v-responsive>
  22. <div class="advice">
  23. {{ $t("click_on_land_to_go_there") }}
  24. </div>
  25. <v-row class="map-shortcuts">
  26. <v-col v-for="shortcut in shortcuts" :key="shortcut.src" cols="2">
  27. <div @click="setMapBounds(shortcut.bounds)">
  28. <nuxt-img
  29. :src="shortcut.src"
  30. :alt="shortcut.alt"
  31. />
  32. </div>
  33. </v-col>
  34. </v-row>
  35. </LayoutContainer>
  36. </template>
  37. <script>
  38. export default {
  39. data () {
  40. const defaultCenter = [46.71, 1.94]
  41. const defaultZoom = 5.75
  42. const defaultBounds = [[51.03, -5.78], [41.2, 9.70]]
  43. return {
  44. defaultCenter,
  45. defaultZoom,
  46. defaultBounds,
  47. center: defaultCenter,
  48. zoom: defaultZoom,
  49. bounds: defaultBounds,
  50. shortcuts: [
  51. { src: '/images/metropole.png', alt: 'Metropole', bounds: { x1: 51.03, y1: -5.78, x2: 41.2, y2: 9.70 } },
  52. { src: '/images/guadeloupe.png', alt: 'Guadeloupe', bounds: { x1: 16.62, y1: -62.03, x2: 15.74, y2: -60.97 } },
  53. { src: '/images/martinique.png', alt: 'Martinique', bounds: { x1: 14.95, y1: -61.43, x2: 14.28, y2: -60.60 } },
  54. { src: '/images/mayotte.png', alt: 'Mayotte', bounds: { x1: -12.51, y1: 44.86, x2: -13.19, y2: 45.45 } },
  55. { src: '/images/la_reunion.png', alt: 'La Réunion', bounds: { x1: -20.65, y1: 54.92, x2: -21.65, y2: 56.15 } },
  56. { src: '/images/guyane.png', alt: 'Guyane', bounds: { x1: 6.24, y1: -54.62, x2: 1.87, y2: -50.59 } }
  57. ]
  58. }
  59. },
  60. methods: {
  61. setMapBounds (bounds) {
  62. // const map = this.$el.querySelector('#map')
  63. // console.log(map)
  64. // map.$emit('boundsUpdated', [bounds.x1, bounds.y1, bounds.x2, bounds.y2])
  65. // this.bounds = latLngBounds([bounds.x1, bounds.y1], [bounds.x2, bounds.y2])
  66. this.bounds = [[bounds.x1, bounds.y1], [bounds.x2, bounds.y2]]
  67. }
  68. }
  69. }
  70. </script>
  71. <style scoped>
  72. #map {
  73. height: 100%;
  74. width: 100%;
  75. }
  76. .advice {
  77. margin: 1rem 0;
  78. color: #262626;
  79. font-weight: 750;
  80. text-align: center;
  81. font-size: 0.9rem;
  82. width: 100%;
  83. }
  84. .map-shortcuts .col {
  85. padding: 12px 6px;
  86. }
  87. .map-shortcuts img {
  88. border: solid 1px #000;
  89. width: 75px;
  90. height: 75px;
  91. }
  92. </style>