Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better CSS loading #1

Closed
xpuu opened this issue Jan 6, 2019 · 2 comments
Closed

Better CSS loading #1

xpuu opened this issue Jan 6, 2019 · 2 comments

Comments

@xpuu
Copy link

xpuu commented Jan 6, 2019

You can load leaflet CSS also in the nuxt plugin via:
import 'leaflet/dist/leaflet.css'

p.s. Your guide helped a lot! Many thanks...

@M-Gregoire
Copy link
Owner

Glad I could help, I added your suggestion to the README

Thanks for contributing!

@joaquimds
Copy link

joaquimds commented Dec 3, 2019

@M-Gregoire Thanks so much for your guide!

Sadly this neat solution to the Icon loading challenge didn't work for me – the normal marker-icon.png loaded, but marker-icon-2x.png and marker-shadow.png did not. I'm afraid I don't understand enough about the internals of Nuxt to figure out what was going on.

This is what worked for me:

import Vue from 'vue'

import 'leaflet/dist/leaflet.css'
import { Icon } from 'leaflet'
import { LMap, LMarker, LTileLayer } from 'vue2-leaflet'

delete Icon.Default.prototype._getIconUrl
Icon.Default.mergeOptions({
  iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
  iconUrl: require('leaflet/dist/images/marker-icon.png'),
  shadowUrl: require('leaflet/dist/images/marker-shadow.png')
})

const VueLeaflet = {
  install(Vue) {
    Vue.component('LMap', LMap)
    Vue.component('LMarker', LMarker)
    Vue.component('LTileLayer', LTileLayer)
  }
}

Vue.use(VueLeaflet)

export default VueLeaflet

It's a brute force solution, but it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants