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, it's just that I can't 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: t.addLayer is not a function
at i.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]);                         
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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.