Skip to content

[BUG] Labels, places and street names not showing and getting "Cancelled" error #71

@riccardodebellini

Description

@riccardodebellini

Package

vector_map_tiles_pmtiles

Bug Description

The map is very laggy and slow on zoom/pan/movement in general, and doesn't display any street name / building labels (schools, transportation..).

Steps to Reproduce

1.Run the code
2. Zoom/move around

Expected Results

The map should

  • move fluidly
  • show street names (curved according to the movement of the street) and building labels

Video

Actual Results

The map

  • Is slow (i get errors such as [1])
  • Doesn't show labels (i get errors such as [2])

[1]

======== Exception caught by image resource service ================================================
The following CancellationException was thrown:
Cancelled

When the exception was thrown, this was the stack: 
====================================================================================================

======== Exception caught by image resource service ================================================
The following CancellationException was thrown:
Cancelled

When the exception was thrown, this was the stack: 
#0      TileLoader._renderTile (package:vector_map_tiles/src/raster/tile_loader.dart:72:7)
#1      TileLoader._renderJob (package:vector_map_tiles/src/raster/tile_loader.dart:66:40)
#2      ImmediateExecutor.submit (package:executor_lib/src/immdediate_executor.dart:17:44)
#3      ConcurrencyExecutor._startJob (package:executor_lib/src/concurrency_executor.dart:74:10)
#4      ConcurrencyExecutor._startJobs (package:executor_lib/src/concurrency_executor.dart:59:7)
#5      ConcurrencyExecutor._startJob.<anonymous closure> (package:executor_lib/src/concurrency_executor.dart:81:7)
<asynchronous suspension>
(elided 5 frames from dart:async)
====================================================================================================

[2]

, {}, [coalesce, [get, pgf:name], [get, name]], {text-font: [case, [==, [get, script], Devanagari], [literal, [Noto Sans Devanagari Regular v1]], [literal, [Noto Sans Regular]]]}, 
, {}, [coalesce, [get, pgf:name3], [get, name3]], {text-font: [case, [==, [get, script3], Devanagari], [literal, [Noto Sans Devanagari Regular v1]], [literal, [Noto Sans Regular]]]}], [format, [coalesce, [get, name:en], [get, pgf:name3], [get, name3]], {}, 
, {}, [coalesce, [get, pgf:name], [get, name]], {text-font: [case, [==, [get, script], Devanagari], [literal, [Noto Sans Devanagari Regular v1]], [literal, [Noto Sans Regular]]]}, 
, {}, [coalesce, [get, pgf:name2], [get, name2]], {text-font: [case, [==, [get, script2], Devanagari], [literal, [Noto Sans Devanagari Regular v1]], [literal, [Noto Sans Regular]]]}]]]]

Video

Code Sample

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:vector_map_tiles/vector_map_tiles.dart';
import 'package:vector_map_tiles_pmtiles/vector_map_tiles_pmtiles.dart';
import 'package:vector_tile_renderer/vector_tile_renderer.dart' as vtr;

/// TODO: use your own tile source https://docs.protomaps.com/pmtiles/cloud-storage
/// This can be a hosted file or local file in your file system,
/// However, flutter assets are not supported.
const String tileSource =
    'https://demo-bucket.protomaps.com/v4.pmtiles';

class VectorMapTilesPmTilesPage extends StatelessWidget {
  VectorMapTilesPmTilesPage({super.key});

  /// The theme specifies the look of the rendered map.
  ///
  /// Note: Styles from Mapbox, OpenMapTiles and others and not compatible
  /// with Protomaps styles.
  final vtr.Theme mapTheme = ProtomapsThemes.lightV4(
    logger: kDebugMode ? const vtr.Logger.console() : null,
  );

  final _futureTileProvider = PmTilesVectorTileProvider.fromSource(tileSource);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        title: const Text('vector_map_tiles_pmtiles'),
      ),
      body: FutureBuilder<PmTilesVectorTileProvider>(
        future: _futureTileProvider,
        builder: (context, snapshot) {
          if (snapshot.hasData) {
            final tileProvider = snapshot.data!;
            return FlutterMap(
              options: const MapOptions(
                initialCenter: LatLng(43.787942, 11.237517), // firenze
                maxZoom: 18,
                minZoom: 0,
              ),
              children: [
                VectorTileLayer(
                  // disable the file cache when you change the PMTiles source
                  fileCacheTtl: Duration.zero,
                  theme: mapTheme,
                  showTileDebugInfo: true,
                  tileProviders: TileProviders({
                    'protomaps': tileProvider,
                  }),
                ),
              ],
            );
          }
          if (snapshot.hasError) {
            debugPrint(snapshot.error.toString());
            debugPrintStack(stackTrace: snapshot.stackTrace);
            return Center(child: Text(snapshot.error.toString()));
          }
          return const Center(child: CircularProgressIndicator());
        },
      ),
    );
  }
}

Platforms

windows

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions