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);
    });

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

相关内容

热门资讯

WPK模拟器方式!拱趴大菠萝万... WPK模拟器方式!拱趴大菠萝万能挂,智星菠萝德州ai多功能透视挂技巧1、拱趴大菠萝万能挂辅助器安装包...
WPK德州局秘籍!拱趴大菠萝辅... WPK德州局秘籍!拱趴大菠萝辅助神器,微扑克ai多功能辅助器脚本1、金币登录送、破产送、升级送、活动...
WPK安装手筋!德扑之星有辅助... WPK安装手筋!德扑之星有辅助软件吗,微扑克ai多功能透视脚本德扑之星有辅助软件吗能透视中分为三种模...
WPK方法秘籍!werplan... WPK方法秘籍!werplan外挂,德扑之星ai多功能开挂神器1、这是跨平台的werplan外挂轻量...
WPK私人局总结!德州局透视,... WPK私人局总结!德州局透视,wpkai多功能开挂教程1)德州局透视辅助插件:进一步探索德州局透视辅...
WPK安卓操作!aapoker... WPK安卓操作!aapoker辅助工具安全吗,微扑克ai多功能辅助软件1、金币登录送、破产送、升级送...
WPK透视窍门!AApoker... WPK透视窍门!AApoker软件,aapokerai多功能辅助神器1、实时AApoker软件透视辅...
WPK脚本烘培!aapoker... WPK脚本烘培!aapoker辅助怎么用,WePoKerai多功能透视挂技巧1、全新机制【aapok...
WPK软件法子!aapoker... WPK软件法子!aapoker公共底牌,红龙扑克ai多功能开挂工具1、aapoker公共底牌公共底牌...
WPK靠谱秘籍!AApoker... WPK靠谱秘籍!AApoker插件,WePoKerai多功能透视挂方法1、实时AApoker插件透视...