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真是存在有挂,aapoker真是真的有挂(详细辅助工具存在教程)1、透视辅助...
透视辅助!aapoker安卓版... 1、透视辅助!aapoker安卓版辅助,aa poker辅助软件其实真的有挂(详细有猫腻教程);详细...
透视辅助!wPk辅助软件,wp... 透视辅助!wPk辅助软件,wpk总结一直是有挂(详细有透视辅助教程)1、下载好辅助软件之后点击打开,...
推荐一款!!德扑有挂真是,德扑... 推荐一款!!德扑有挂真是,德扑网上切实有挂(详细平台教程)1、超多福利:超高返利,海量正版游戏,系统...
黑科技辅助!wopoker透明... 黑科技辅助!wopoker透明挂辅助软件,Wepoke德州版本原来是有挂(详细ai辅助教程);1)辅...
wepoke有辅助挂!wepo... wepoke有辅助挂!wepoke辅助机器人,(Wepoke必胜)确实是真的有挂(详细辅助挂教程)1...
透视辅助!Aapoker软件透... 透视辅助!Aapoker软件透明挂,aapoker透明挂本来是有挂(详细辅助教程);1、完成aapo...
透视辅助!wpk微扑克有辅助,... 透视辅助!wpk微扑克有辅助,(wpk规律)切实真的是有挂(详细真的有外卦挂教程)1、许多玩家不知道...
黑科技透明挂!WePoKer确... 黑科技透明挂!WePoKer确实有挂,Wepoke大厅房确实是有挂(详细辅助机器人教程);1、打开软...
第十分钟了解!微扑克辅助挂,微... 第十分钟了解!微扑克辅助挂,微扑克数据都是存在有挂(详细有辅助挂教程);1、让任何用户在无需微扑克辅...