Vue Leaflet map tiles in wrong order

陌路散爱 提交于 2020-02-02 11:28:27

问题


I just trying Vue Leaflet and trying to use this example. But when I try it in my local server, the map has wrong order.

Here's my code

<template>
  <div class="home">
    <l-map :zoom="zoom" :center="center">
      <l-tile-layer :url="url" :attribution="attribution"></l-tile-layer>
      <l-polygon v-for="s in shapes"
                   :key="s.id"
                   :color="s.color"
                   :lat-lngs="s.geometry.coordinates"
                   @l-mouseover=change_color(s)
                   >
        </l-polygon>
    </l-map>
  </div>
</template>

<script>
import { LMap, LPolygon, LTileLayer } from 'vue2-leaflet'
export default {
  components: { LMap, LPolygon, LTileLayer },
  name: 'home',
  data () {
    return {
      zoom: 7,
      center: [47.413220, -1.219482],
      url: 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
      attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
      shapes: [
        {
          id: 'my_id',
          color: '#3388ff',
          geometry: {
            coordinates: [
              [[[47, -1], [47, 0], [48, 0], [48, -1], [47, -1]]]
            ]
          }
        }
      ]
    }
  },
  methods: {
    change_color (shape) {
      shape.color = '#ee0000'
    }
  }
}
</script>

I can't figure out what happened. Any ideas? Thank you.


回答1:


Solved by import the CSS files.



来源:https://stackoverflow.com/questions/58723390/vue-leaflet-map-tiles-in-wrong-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!