最近因为工作需要,在研究openlayers地图的使用,但是卡在了地图标记这块,不论我怎么尝试,标记就是不会显示在地图上,反反复复看了很多博客,也研究了文档,都觉得没有问题,也用html尝试了,标记可以显示,但就是在我的vue项目中显示不出来,后来发现是图片引入的问题。
刚开始我是这样引入图片的:
但是,在vue中动态引入图片应该使用require或者import,下边是正确的做法,完整代码,方便研究openlayers的小伙伴也可以顺便借鉴一下:
首先,npm install ol
最近因为工作需要,在研究openlayers地图的使用,但是卡在了地图标记这块,不论我怎么尝试,标记就是不会显示在地图上,反反复复看了很多博客,也研究了文档,都觉得没有问题,也用html尝试了,标记可以显示,但就是在我的vue项目中显示不出来,后来发现是图片引入的问题。
刚开始我是这样引入图片的:
但是,在vue中动态引入图片应该使用require或者import,下边是正确的做法,完整代码,方便研究openlayers的小伙伴也可以顺便借鉴一下:
首先,npm install ol