简体   繁体   中英

JavaScript Leaflet Map not loading

I need multiple maps on my page, both 2Gis and Leaflet. The 2Gis itself is based on the Leaflet library. The 2Gis is working fine. The Leaflet works only without the 2Gis. Together with 2Gis it throws an error:

"TypeError: Leaflet.tileLayer.Unwired is not a function" at this line:

var myLeafletStreets = Leaflet.tileLayer.Unwired({ // <- ERROR HERE

Looks like there's a conflict between the 2 but I can't pin point where.

Here's a fiddle: https://jsfiddle.net/tL31gnxz/

If you remove the 2Gis bit:

DG.then(function() {
    InitTwoGisMap();
});

the Leaflet map loads fine.

What's the problem with Leaflet?

I'm using

var Leaflet = L.noConflict();

but it doesn't seem to help.

try like this

var myLeafletStreets = Leaflet.tileLayer({ // <- ERROR HERE
            key: 'pk.b2fa80c148d22bfa3f1d0e2347ddf3f6', 
            scheme: "streets",
        });

working fiddle

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