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

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

相关内容

热门资讯

透视玄学!xpoker辅助怎么... 透视玄学!xpoker辅助怎么用(透视)好像真的是有挂(详细辅助辅助教程)1)辅助挂:进一步探索辅助...
推荐十款!hhpoker辅助器... 推荐十款!hhpoker辅助器视频,wpk俱乐部辅助器,必胜教程(有挂教程);支持2-10人实时对战...
透视计算!hhpoker脚本下... 透视计算!hhpoker脚本下载(透视)好像是有挂(详细辅助细节揭秘)1、ai辅助优化,发牌逻辑科技...
每日必看推荐!wepoker破... 每日必看推荐!wepoker破解器有用吗,wepoker辅助器官方,技巧教程(有挂神器)准备好在we...
透视好友房!wepoker怎么... 透视好友房!wepoker怎么发冤家牌(透视)一贯有挂(详细辅助黑科技教程)1、在ai机器人技巧中,...
实测必看!wepoker可以免... 实测必看!wepoker可以免费玩吗,wepoker的辅助器,黑科技教程(有挂透明)是一款可以让一直...
透视能赢!大菠萝789辅助器下... 透视能赢!大菠萝789辅助器下载(透视)都是真的是有挂(详细辅助wpk教程)透视能赢!大菠萝789辅...
新手必备!hhpoker德州挂... 新手必备!hhpoker德州挂真的有吗,wepoker免费透视,辅助教程(有挂透明);实战中需综合运...
透视透视!wepoker有脚本... 透视透视!wepoker有脚本吗(透视)好像真的是有挂(详细辅助系统教程)软件透明挂微扑克wpk插件...
必看攻略!aapoker脚本,... 必看攻略!aapoker脚本,aapoker怎么提高中牌率,专业教程(有挂透视);支持2-10人实时...