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

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

相关内容

热门资讯

透视曝光"aapok... 透视曝光"aapoker脚本怎么用"本来真的有辅助脚本(哔哩哔哩)1、该软件可以轻松地帮助玩家将aa...
透视曝光"poker... 透视曝光"poker world辅助"都是真的是有辅助方法(哔哩哔哩)进入游戏-大厅左侧-新手福利-...
透视辅助"wpk控制... 透视辅助"wpk控制牌是真的吗"一直真的有辅助挂(哔哩哔哩)1、起透看视 wpk控制牌是真的吗辅助软...
透视了解"wepok... 透视了解"wepoker永久免费脚本"原来是真的辅助挂(哔哩哔哩)1、在wepoker永久免费脚本插...
透视总结"wepok... 透视总结"wepoker私人局透视方法"总是有辅助工具(哔哩哔哩);1、任何wepoker私人局透视...
透视揭露"wepok... 透视揭露"wepoker辅助器激活码"一贯存在有辅助挂(哔哩哔哩)1、wepoker辅助器激活码透视...
透视科普"wepok... 透视科普"wepoker有透视底牌吗"真是存在有辅助教程(哔哩哔哩)1、起透看视 wepoker有透...
透视揭幕"wepok... 透视揭幕"wepoker插件功能辅助器"都是是真的辅助神器(哔哩哔哩)1、进入到wepoker插件功...
透视关于"werpl... 透视关于"werplan透视挂"切实真的有辅助神器(哔哩哔哩)1、下载好werplan透视挂正确养号...
透视推荐"we-po... 透视推荐"we-poker辅助软件教程"果然存在有辅助攻略(哔哩哔哩)1、游戏颠覆性的策略玩法,独创...