Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

515
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda