简体   繁体   English

JavaScript Leaflet Map未加载

[英]JavaScript Leaflet Map not loading

I need multiple maps on my page, both 2Gis and Leaflet. 我的页面上需要多个地图,包括2Gis和Leaflet。 The 2Gis itself is based on the Leaflet library. 2Gis本身基于Leaflet库。 The 2Gis is working fine. 2Gis工作正常。 The Leaflet works only without the 2Gis. 传单仅在没有2Gis的情况下工作。 Together with 2Gis it throws an error: 与2Gis一起,它会抛出一个错误:

"TypeError: Leaflet.tileLayer.Unwired is not a function" at this line: 此行上的“TypeError:Leaflet.tileLayer.Unwired不是函数”:

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

Looks like there's a conflict between the 2 but I can't pin point where. 看起来2之间存在冲突,但我不能指出哪里。

Here's a fiddle: https://jsfiddle.net/tL31gnxz/ 这是一个小提琴: https//jsfiddle.net/tL31gnxz/

If you remove the 2Gis bit: 如果你删除2Gis位:

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

the Leaflet map loads fine. 宣传单地图加载正常。

What's the problem with Leaflet? 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 工作小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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