android 与使用flutter_map_tile_caching的WMS切片图层选项(WMSTileLayerOptions未缓存)相关的问题:8.0.0

r8xiu3jd  于 2023-05-27  发布在  Android
关注(0)|答案(1)|浏览(175)

我正在使用flutter_map_tile_cache库缓存切片,但无法缓存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:无法从该高速缓存或网络加载切片,因为缓存中缺少该切片,并且无法建立与服务器的连接。

2lpgd968

2lpgd9681#

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(),
      ),

相关问题