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

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

相关内容

热门资讯

3分钟辅助!hhpoker辅助... 3分钟辅助!hhpoker辅助器,德普之星辅助软件,练习教程(有挂猫腻)1、下载好德普之星辅助软件脚...
一分钟辅助!hh poker辅... 一分钟辅助!hh poker辅助器先试用,wepoker是不是有人用挂,烘培教程(有挂解惑)1、we...
第8分钟辅助!wepoker代... 第8分钟辅助!wepoker代打辅助,wpk软件是正规的吗,指南教程(有挂分析)1、操作简单,无需w...
第八分钟辅助!wepoker公... 第八分钟辅助!wepoker公共底牌,德普软件,办法教程(真实有挂)wepoker公共底牌脚本下载中...
第1分钟辅助!wepoker有... 第1分钟辅助!wepoker有辅助吗,aa poker透视软件,手册教程(有挂教学)1、实时aa p...
9分钟辅助!wepoker软件... 9分钟辅助!wepoker软件辅助程序,wpk透视辅助下载,方针教程(证实有挂)1、很好的工具软件,...
九分钟辅助!wepoker透视... 九分钟辅助!wepoker透视版下载,uupoker透视,窍要教程(有挂解密)1、wepoker透视...
第2分钟辅助!wepoker挂... 第2分钟辅助!wepoker挂,wpk透视辅助,手册教程(的确有挂)wpk透视辅助透视方法中分为三种...
第7分钟辅助!wepokerp... 第7分钟辅助!wepokerplus到底是挂了吗,sohoopoker辅助,指南书教程(有挂攻略)1...
八分钟辅助!aapoker破解... 八分钟辅助!aapoker破解侠是真的吗,aapoker怎么设置提高好牌几率,窍门教程(有挂透视)1...