【问题标题】:How can I resolve this Leaflet error? getPixelWorldBounds()如何解决此传单错误? getPixelWorldBounds()
【发布时间】:2017-10-03 17:50:56
【问题描述】:

有谁知道在尝试创建传单地图时可能导致以下错误的原因是什么?它与自定义 CRS 有关。由于各种原因,我无法发布太多代码,所以如果有人能指出我正确的方向,我将不胜感激。

this._map.getPixelWorldBounds() 为空

L.map(containerId, {
    maxBounds: L.latLngBounds(L.latLng(-90, -180), L.latLng(90,180)),
    maxZoom: 15,
    minZoom: 1,
    center: centerLatLng,
    zoom: 2,
    crs: getCrs(),
    worldCopyJump: true,
    zoomControl: false,
    attributionControl: false
});

function getCrs() {
    return new L.Proj.CRS('EPSG:4326', '+proj=longlat +datum=WGS84 +no_defs', {
        origin: [-180, 90],
        tileSize: 512,
        resolutions: [...]
    });
}
//Removed resolutions for brevity.

【问题讨论】:

  • 谢谢。我目前无法访问该网站 - 但我会尽快查看。我确实将我的 getCrs() 更改为 L.CRS.EPSG4326 并修复了错误。我想我需要检查该自定义函数以了解其导致问题的原因。

标签: javascript reactjs leaflet proj4js


【解决方案1】:

我确实遇到了这个问题,通过使用 Proj4Leaflet 将 EPSG:32661 支持添加到 Leaflet。

Uncaught TypeError: Cannot read property 'getSize' of null
    at NewClass._onZoomEnd (leaflet-src.js?8af6:13235)
    at NewClass.whenReady (leaflet-src.js?8af6:4450)
    at NewClass.addHooks (leaflet-src.js?8af6:13157)
    at NewClass.enable (leaflet-src.js?8af6:5722)
    at NewClass.addHandler (leaflet-src.js?8af6:3736)
    at NewClass.init (leaflet-src.js?8af6:385)
    at NewClass.proto.callInitHooks (leaflet-src.js?8af6:357)
    at NewClass.initialize (leaflet-src.js?8af6:3148)
    at new NewClass (leaflet-src.js?8af6:301)
    at Map.createLeafletElement (Map.js?fe6c:87)

我发现问题是通过使用worldCopyJump 引起的。删除它,错误就会消失。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-12
    • 2012-02-14
    • 2015-04-12
    • 2016-06-21
    • 2020-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多