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

506
Vistas
How to solve map.addlayer not a function

I am trying to implement the leaflet-panel-layer plugin and customize the included overlay to my needs. The original code uses a geojson formatted as js and I use a basic js marker list (which I load in from a seperate document) so I am wondering what I have to change to show the markers. I already got some parts of the map working e.g. choosing between baselayers but I can´t get the overlaylayers to work how I want.

I think the loading in isn´t the problem here, its just that I cant add the markers to the map, because the follwing Error seems to have to do something with how and where the map is definined (info from other people with similar error message)

``leaflet.js:5 Uncaught TypeError: map.addLayer is not a function        
  at NewClass.addTo (leaflet.js:5:64472)
  at URD_Regio.js:105:284``

How I load in the js files with the Markers in them:

<script src="js/URD_Regio.js"></script>                                                  
<script src="js/URD_Fernverkehr.js"></script>

How I define my markers (in the mentioned external js file) and how I group them:

var ulm_1 = L.marker([44.7892, 9.745775]);
ulm_1.bindPopup('<b>.....');                                                                
var db_regio = L.layerGroup ([ulm_1],......).addTo(map)

I have tried adding the addTo(map) command in several places but pretty much always got the same error.

My current code:

var overLayers = [
{
    group: "data",
    collapsed: true,
    layers: [
        {
            active: false,
            name: "Drinking Water",
            layer: L.layerGroup(db_regio) //.addTo(map)?
        },

Note when implementing the original code which uses a geojson formatted as js, the code works just fine.

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