Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

503
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!