AutozoominLeaflet/MapboxPowerBIPluginsworkingerratically
创始人
2024-11-12 16:30:41
0

Autozoom插件问题的解决方案是检查并更新代码以使用Mapbox GL JS库,并确保正确设置视图范围,以便正确缩放至所有要素。以下是更新过的Autozoom插件的代码示例:

    // 旧代码
    L.DomEvent.on(map, map instanceof L.Map ? 'moveend' : 'ready', function() {
        var fitBoundsOptions = {};
        if (this.dimensions && L.Util.isArray(this.dimensions) && this.dimensions.length === 2) {
            // need to make a geojson line
            var coords = this.dimensions
            var line = {
                type: 'LineString',
                coordinates: [coords]
            };
            var b = L.geoJSON(line, {
                style: this.style
            }).getBounds();
            fitBoundsOptions = {
                paddingTopLeft: [5, 5],
                paddingBottomRight: [5, 5]
            };
            map.fitBounds(b, fitBoundsOptions);
        } else if (this.dimensions) {
            map.fitBounds(this.dimensions, fitBoundsOptions);
        } else {
            var markers = featureLayer.getLayers();
            var group = new L.featureGroup(markers);
            map.fitBounds(group.getBounds(), fitBoundsOptions);
        }
    });

    // 新代码
    map.on('load', function() {
        var fitBoundsOptions = {};
        const bounds = map.getSource('my-data')._data.features.reduce((bounds, feature) => {
            return bounds.extend(turf.bbox(feature));
        }, new mapboxgl.LngLatBounds());
        map.fitBounds(bounds, fitBoundsOptions);
    });

重要的是要注意不同代码库之间的差异,并确保使用正确的库和方法调用。

相关内容

热门资讯

受玩家影响!aapoker脚本... 受玩家影响!aapoker脚本怎么用,德普之星透视辅助软件是真的吗,总是是有挂(有挂存在)1、进入游...
现有关情况通报如下!we po... 现有关情况通报如下!we poker辅助器v3.3,智星菠萝有挂吗,果然真的有挂(揭秘有挂)智星菠萝...
备受关注的!wepoker辅助... 备受关注的!wepoker辅助软件视频,德普之星辅助器app,本来是有挂(新版有挂)运德普之星辅助器...
2026版复盘!wepoker... 2026版复盘!wepoker手机插件,德普之星有透视辅助吗,好像真的有挂(有挂讲解)1、任何德普之...
为了进一步!wepoker游戏... 为了进一步!wepoker游戏安装教程,德普之星透视辅助软件,确实确实有挂(有挂分析)该软件可以轻松...
近年来!pokemmo内置修改... 近年来!pokemmo内置修改器,德扑之星透视软件免费入口官网,竟然是真的有挂(有挂方针)1)德扑之...
插件辅助挂!wpk辅助软件,德... 插件辅助挂!wpk辅助软件,德扑之星透视免费,确实真的有挂(有挂方法)1、打开软件启动之后找到中间准...
现有关情况通报如下!wpk安卓... 您好,德普之星透视辅助软件是真的吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【1367043...
2026版软件!pokemmo... 2026版软件!pokemmo脚本辅助器下载,德普之星私人局透视,确实真的是有挂(有挂方略)1、很好...
据悉!wepoker黑侠破解,... 据悉!wepoker黑侠破解,德普之星app安卓版破解版,总是确实有挂(新版有挂)1、金币登录送、破...