Issues related to WMS tile layer options (WMSTileLayerOptions not caching) using flutter_map_tile_caching: ^8.0.0

huangapple go评论67阅读模式
英文:

Issues related to WMS tile layer options (WMSTileLayerOptions not caching) using flutter_map_tile_caching: ^8.0.0

问题

I am using 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:无法从缓存或网络加载瓦片,因为缓存中缺少该瓦片并且无法建立与服务器的连接。

英文:

I am using flutter_map_tile_cache lib to cache tile but I am not able to cache WMSTileLayerOptions layers please provide any solution

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

getting error like this:- FMTCBrowsingError: Failed to load the tile from the cache or the network because it was missing from the cache and a connection to the server could not be established.

答案1

得分: 0

以下是翻译好的部分:

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

希望这对你有帮助。如果有其他翻译需求,请告诉我。

英文:

The flutter libraries "flutter_map" and "cached_network_image" can fulfill our requirements.

We need to implement like this:

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

And

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

huangapple
  • 本文由 发表于 2023年5月26日 13:42:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76337938.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定