简体   繁体   中英

Uncaught TypeError: ctlLayers.addOverLay is not a function

I'm trying to insert an ajax script in my index.php where I call a leaflet Methods ( addOverlay ) ctlLayers.addOverLay(lyrEagleNests, "Eagle Nests") but I get this error:

    Uncaught TypeError: ctlLayers.addOverLay is not a function
    at Object.success (djbasin_client.php:358)
    at u (jquery-3.3.1.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-3.3.1.min.js:2)
    at k (jquery-3.3.1.min.js:2)
    at XMLHttpRequest.<anonymous> (jquery-3.3.1.min.js:2)
success @ djbasin_client.php:358
u @ jquery-3.3.1.min.js:2
fireWith @ jquery-3.3.1.min.js:2
k @ jquery-3.3.1.min.js:2
(anonymous) @ jquery-3.3.1.min.js:2
load (async)
send @ jquery-3.3.1.min.js:2
ajax @ jquery-3.3.1.min.js:2
(anonymous) @ djbasin_client.php:354
l @ jquery-3.3.1.min.js:2
c @ jquery-3.3.1.min.js:2
setTimeout (async)
(anonymous) @ jquery-3.3.1.min.js:2
u @ jquery-3.3.1.min.js:2
fireWith @ jquery-3.3.1.min.js:2
fire @ jquery-3.3.1.min.js:2
u @ jquery-3.3.1.min.js:2
fireWith @ jquery-3.3.1.min.js:2
ready @ jquery-3.3.1.min.js:2
_ @ jquery-3.3.1.min.js:2

Below I also upload the script:

               $.ajax({url:'load_baea.php',
                    success:function(response){
                        jsnEagles = JSON.parse(response);
                        lyrEagleNests = L.geoJSON(jsnEagles, {pointToLayer:returnEagleMarker, filter:filterEagle}).addTo(mymap);
                        ctlLayers.addOverLay(lyrEagleNests, "Eagle Nests")
                        arEagleIDs.sort(function(a,b){return a-b});
                        $("#txtFindEagle").autocomplete({
                        source:arEagleIDs
                });

Here some images about the method: 在此处输入图像描述

You have ot write addOverlay with a lowercase L :

$.ajax({url:'load_baea.php',
                    success:function(response){
                        jsnEagles = JSON.parse(response);
                        lyrEagleNests = L.geoJSON(jsnEagles, {pointToLayer:returnEagleMarker, filter:filterEagle}).addTo(mymap);
                        ctlLayers.addOverlay(lyrEagleNests, "Eagle Nests")
                        arEagleIDs.sort(function(a,b){return a-b});
                        $("#txtFindEagle").autocomplete({
                        source:arEagleIDs
                });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM