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俱乐部!红龙PoKer工... WPK俱乐部!红龙PoKer工具辅助器ai,德普之星透视,一贯是真的有ai辅助器妙招1、进入到德普之...
WPK透视!智星菠萝德州教程透... WPK透视!智星菠萝德州教程透视挂ai,werplan有挂吗,其实是真的有ai透视挂绝活儿1、wer...
WPK官网!wpk插件透视挂a... WPK官网!wpk插件透视挂ai,wpk作弊最怕三个东西,果然存在有ai透视挂指南1、用户打开应用后...
WPK四人!德扑之星教程辅助a... WPK四人!德扑之星教程辅助ai,德州私人局脚本,一直是真的有ai辅助方式1、德州私人局脚本脚本辅助...
WPK透视版!智星菠萝德州软件... WPK透视版!智星菠萝德州软件辅助器ai,约局吧德州真的存在透视吗,确实是有ai辅助器操作1、每一步...
WPK有透视!菠萝智星德州工具... WPK有透视!菠萝智星德州工具透视挂ai,wpk可以作弊吗,本来真的是有ai透视挂积累运wpk可以作...
WPK辅助器!红龙扑克插件透视... WPK辅助器!红龙扑克插件透视挂ai,德州局脚本,一直存在有ai透视挂烘培1、很好的工具软件,可以解...
WPK链接!wpkapp透视挂... WPK链接!wpkapp透视挂ai,AApoker俱乐部,一贯有ai透视挂操作1、WPK链接!wpk...
WPK德州局!微扑克技巧辅助器... WPK德州局!微扑克技巧辅助器ai,德扑之心免费透视,原来真的是有ai辅助器指南1、很好的工具软件,...
WPK软件!德扑之星方法辅助a... WPK软件!德扑之星方法辅助ai,aapoker真的假的,真是真的有ai辅助指南1、点击下载安装,a...