使用 flutter_map_tile_caching 与 WMS 图块图层选项(WMSTileLayerOptions 不缓存)相关的问题:^8.0.0

问题描述 投票:0回答:1

我正在使用 flutter_map_tile_cache lib 来缓存图块,但我无法缓存 WMSTileLayerOptions 图层,请提供任何解决方案

     TileLayer(
        wmsOptions: WMSTileLayerOptions(
          baseUrl: 'https://apps.xyz.com:8080/myserver/wms/?',
          layers: ['XYZLAYER:stateboundary],
          format: 'image/png',
          transparent: true,
        ),
        backgroundColor: Colors.transparent,
        userAgentPackageName: 'com.example.xyz',
        tileProvider: FMTC.instance('mapStore').getTileProvider(),
      ),

出现如下错误:- FMTCBrowsingError:无法从缓存或网络加载图块,因为缓存中缺少该图块并且无法建立与服务器的连接。

android ios flutter fluttermap
1个回答
0
投票

flutter 库“flutter_map”和“cached_network_image”可以满足我们的要求。

我们需要这样实现:

class CachedNetworkTileProvider extends TileProvider {
    @override
    ImageProvider getImage(TileCoordinates coordinates, TileLayer options) 
    {
     return CachedNetworkImageProvider(getTileUrl(coordinates, options));
    }
}

还有

 TileLayer(wmsOptions: WMSTileLayerOptions(
          baseUrl: 'https://apps.example.com:8080/myserver/wms/?',
          layers: ['XYZLAYER:stateboundary'],
          format: 'image/png',
          transparent: true,
        ),
        backgroundColor: Colors.transparent,
        userAgentPackageName: 'com.example.xyz',
        tileProvider: CachedNetworkTileProvider(),
      ),
© www.soinside.com 2019 - 2024. All rights reserved.