Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
How to use a SVG Icon with leaflet inside a Vue 2 app

I have a Vue 2 sample project at https://github.com/ericg-vue-questions/leaflet-test

(3 questions total)

(1)

How can I include the svg icon directly instead of transferring the definition to a js file and importing via:

import {thecloud} from './TheCloud';

I did try:

const thecloud = require( './TheCloud.svg' );

But that did not work.

Is that possible? If so, how?

(2)

How can I control the size of the icon?

What I have tried is:

      const size = 20;

      const cloudIcon = L.divIcon({
        html: thecloud,
        className: 'my-custom-icons',
        iconSize: [size, size],
        iconAnchor: [size/2, size/2]
      })
      L.marker( from, { icon: cloudIcon} ).addTo( mapDiv );

where the style section looks like:

<style scoped>
  #mapContainer {
    width: 500px;
    height: 500px;
  }
</style>

<style>
  .my-custom-icons {
    background-color: red;
  }
</style>

What I get is:

large-icon

The div is appearing in the correct spot and is sized correctly. I expected the svg icon to appear inside of the div and be constrained by it, but that did not happen.

Why? What do I need to do to fix this?

(3)

Related to #2, I would like the style section to look like:

<style scoped>
  #mapContainer {
    width: 500px;
    height: 500px;
  }

  .my-custom-icons {
    background-color: red;
  }
</style>

But when I place my-custom-icons inside of the components scoped section, the divIcon cannot find it.

Can I organize my style section like this? If so, how?

Thank you.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda