-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Add ability to retrieve raw bytes from internal ImageProvider
(to enable partial compatibilty with vector tiles)
#84
Comments
Hi @GaelleJoubert, |
@JaffaKetchup Thanks you for your answer.
But the
Do you see a way to use both plugging together ? If yes I'll be happy to know how you would do. |
Ah my apologies @GaelleJoubert, I didn't see a reference to FMTC, so I assumed you were talking about FM. Indeed they are incompatible. |
Ah, yeah I thought so ... |
No way for now. PRs are always welcome (use 'next-version' branch if you do) :), but I'm unlikely to work to implement this. PS. My fault for missing your actual point before, didn't realise this was an issue in my repo instead of FM. Apologies :) |
Is there still plan to make this map_tile_caching work with vector_map_tile ? |
There is nothing in the infrastructure and design that would be incompatible with vector tiles: they are bytes just like any other. |
@JaffaKetchup I just tried but it doesn't seem as easy as you make it sound :) A tile provider doesn't provide bytes but an
To get the bytes from the store, If there was a method import 'dart:typed_data';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
import 'package:vector_map_tiles/vector_map_tiles.dart';
import 'package:zs_connect/map/map.dart';
class FmtcVectorTileProvider extends VectorTileProvider {
final tileProvider = const FMTCStore(mapStoreName).getTileProvider();
@override
final int maximumZoom;
@override
final int minimumZoom;
final TileLayer tileLayer;
FmtcVectorTileProvider({
required String urlTemplate,
this.maximumZoom = 16,
this.minimumZoom = 1,
}) : tileLayer = TileLayer(urlTemplate: urlTemplate);
@override
Future<Uint8List> provide(TileIdentity tile) async {
final coordinates = TileCoordinates(tile.x, tile.y, tile.z);
// If there was a method that returned bytes, it could be called here
tileProvider.getTileBytes(coordinates, tileLayer);
}
} What do you think? Did I miss something? |
@micheljung You can try following something like this for now: Baseflow/flutter_cached_network_image#714 (comment). This will load the bytes from the I can look into adding a |
Thank you for your quick reaction @JaffaKetchup. I tried this solution, but it seems like the Image detour corrupts the bytes so they can't be parsed as vector data anymore. I'll give up at this point for now. For anyone interested, here's what I tried. import 'dart:async';
import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
import 'package:vector_map_tiles/vector_map_tiles.dart';
import 'package:zs_connect/map/map.dart';
class FmtcVectorTileProvider extends VectorTileProvider {
final tileProvider = const FMTCStore(mapStoreName).getTileProvider();
final VectorTileProvider delegate;
@override
int get maximumZoom => delegate.maximumZoom;
@override
int get minimumZoom => delegate.minimumZoom;
final TileLayer tileLayer;
FmtcVectorTileProvider({
required this.delegate,
required String urlTemplate,
}) : tileLayer = TileLayer(urlTemplate: urlTemplate);
@override
Future<Uint8List> provide(TileIdentity tile) async {
final coordinates = TileCoordinates(tile.x, tile.y, tile.z);
return await tileProvider.getImage(coordinates, tileLayer).getBytes();
}
}
extension ImageTool on ImageProvider {
Future<Uint8List> getBytes(
// also tried rawRgba
{ImageByteFormat format = ImageByteFormat.rawUnmodified}) async {
final Completer<Uint8List> completer = Completer<Uint8List>();
final ImageStreamListener listener = ImageStreamListener(
(imageInfo, synchronousCall) async {
final bytes = await imageInfo.image.toByteData(format: format);
if (!completer.isCompleted) {
completer.complete(bytes?.buffer.asUint8List());
}
},
);
final imageStream = resolve(ImageConfiguration.empty);
imageStream.addListener(listener);
final imageBytes = await completer.future;
imageStream.removeListener(listener);
return imageBytes;
}
}
|
ImageProvider
(to enable partial compatibilty with vector tiles)
I suppose that makes sense. I've re-opened this, as your suggestion would be relatively easy and shouldn't be exposing too much of the internals. |
What do you want implemented?
I would be able to use vector tiles (.pbf) instead of Raster Tiles (.png).
Indeed my company is rendering our map ourselves, and Vector tile takes much less computation power to render.
The idea is to be able to use url links like :
"https://tiles.stadiamaps.com/data/openmaptiles/{z}/{x}/{y}.pbf?"
To provide the style in a json like file, and to have all the features the library already provide (cache & bulk dowloading).
What other alternatives are available?
There is already another library that handle Vector tiles, but the way it works I am pretty sure it is not compatible with this one.
I'll be happy to be wrong and that both library could be used at the same time.
The library is :
https://github.com/greensopinion/flutter-vector-map-tiles
It does handle caching, but not bulk dowloading.
Can you provide any other information?
No response
Platforms Affected
Android, iOS
Severity
Annoying: Currently have to use workarounds
Requirements
The text was updated successfully, but these errors were encountered: