mapbox-maps-flutter icon indicating copy to clipboard operation
mapbox-maps-flutter copied to clipboard

[Help] How can add tiles another provider.

Open JulioRennan opened this issue 3 years ago • 3 comments

Hi can you help me, that add the tiles from anotter provider? I tried RasterSource and ImageSource, but dont works. the url will be query is like this: "https://example.com.br//radar/tiles/{startDate}{endDate}{x}{y}{z}.png",

JulioRennan avatar Feb 06 '23 20:02 JulioRennan

Hi @JulioRennan, could you share more details, code you've been trying, errors you've faced etc

yunikkk avatar Feb 08 '23 13:02 yunikkk

Hi i solved this with the following code:

final startDate = DateTime.now().millisecondsSinceEpoch;
final endDate = DateTime.now().millisecondsSinceEpoch;

mgController.style.addSource(
          RasterSource(
            id: "raster_source",
            tiles: ["https://example.com.br//radar/tiles/$startDate_$endDate_{x}_{y}_{z}.png"],
            tileSize: 256,
          ),
 );
 
 await mgController.style.addLayer(
      RasterLayer(
        id: "raster_layer",
        sourceId: "raster_source",
      ),
 );

I dont know if is the best pratice to sdk, but was solved. And always the startDate or endDate changes, was added a new Raster Source. Make sense, add an example to this repository with external tiles providers?

JulioRennan avatar Feb 09 '23 18:02 JulioRennan

Hi i solved this with the following code:

final startDate = DateTime.now().millisecondsSinceEpoch;
final endDate = DateTime.now().millisecondsSinceEpoch;

mgController.style.addSource(
          RasterSource(
            id: "raster_source",
            tiles: ["https://example.com.br//radar/tiles/$startDate_$endDate_{x}_{y}_{z}.png"],
            tileSize: 256,
          ),
 );
 
 await mgController.style.addLayer(
      RasterLayer(
        id: "raster_layer",
        sourceId: "raster_source",
      ),
 );

I dont know if is the best pratice to sdk, but was solved. And always the startDate or endDate changes, was added a new Raster Source. Make sense, add an example to this repository with external tiles providers?

This solve my life! Thanks a lot!