admin管理员组

文章数量:1124790

I am using vector_map_tiles together with flutter_map and loading vector map tiles from map tile provider viamap.

I am using the following code to load the tiles (stylesheet seems to load just fine):

VectorTileProvider _tileProvider(String tileUrl) => NetworkVectorTileProvider(urlTemplate: tileUrl, maximumZoom: maxZoom);
VectorTileLayer(
  theme: style.theme,
  sprites: style.sprites,
  maximumZoom: 14,
  tileProviders: TileProviders({'viavector': _tileProvider(tileModel.styleUrl!)})
);

but this gives me a bunch of these errors:

InvalidProtocolBufferException: Protocol message tag had invalid wire type.

I also tried with this code:

VectorTileLayer(
  theme: style.theme,
  sprites: style.sprites,
  tileOffset: TileOffset.mapbox,
  layerMode: VectorTileLayerMode.vector, maximumZoom: 14, tileProviders: TileProviders({'viavector': _tileProvider(tileModel.styleUrl!)})
);

Which basicly gives the same errors, but with more information:

Unhandled Exception: InvalidProtocolBufferException: Protocol message tag had invalid wire type.
E/flutter (17464): #0      UnknownFieldSet.mergeFieldFromBuffer (package:protobuf/src/protobuf/unknown_field_set.dart:80:9)
E/flutter (17464): #1      UnknownFieldSet.mergeFromCodedBufferReader (package:protobuf/src/protobuf/unknown_field_set.dart:88:24)
E/flutter (17464): #2      CodedBufferReader.readUnknownFieldSetGroup (package:protobuf/src/protobuf/coded_buffer_reader.dart:89:21)
E/flutter (17464): #3      UnknownFieldSet.mergeFieldFromBuffer (package:protobuf/src/protobuf/unknown_field_set.dart:71:32)
E/flutter (17464): #4      UnknownFieldSet.mergeFromCodedBufferReader (package:protobuf/src/protobuf/unknown_field_set.dart:88:24)
E/flutter (17464): #5      CodedBufferReader.readUnknownFieldSetGroup (package:protobuf/src/protobuf/coded_buffer_reader.dart:89:21)
E/flutter (17464): #6      UnknownFieldSet.mergeFieldFromBuffer (package:protobuf/src/protobuf/unknown_field_set.dart:71:32)
E/flutter (17464): #7      _mergeFromCodedBufferReader (package:protobuf/src/protobuf/coded_buffer.dart:46:38)
E/flutter (17464): #8      GeneratedMessage.mergeFromBuffer (package:protobuf/src/protobuf/generated_message.dart:192:5)
E/flutter (17464): #9      new VectorTile.fromBuffer (package:vector_tile/raw/proto/vector_tile.pb.dart:340:128)
E/flutter (17464): #10     VectorTile.fromBytes (package:vector_tile/vector_tile.dart:24:33)
E/flutter (17464): #11     VectorTileReader.read. (package:vector_tile_renderer/src/vector_tile_reader.dart:10:25)
E/flutter (17464): #12     Timeline.timeSync (dart:developer/timeline.dart:173:22)
E/flutter (17464): #13     profileSync (package:vector_tile_renderer/src/profiling.dart:16:19)
E/flutter (17464): #14     VectorTileReader.read (package:vector_tile_renderer/src/vector_tile_reader.dart:9:12)
E/flutter (17464): #15     _createTile (package:vector_map_tiles/src/cache/vector_tile_loading_cache.dart:139:44)
E/flutter (17464): #16     _Job.apply (package:executor_lib/src/queue_executor.dart:97:59)
E/flutter (17464): #17     QueueExecutor._runOneAndReschedule (package:executor_lib/src/queue_executor.dart:52:34)
E/flutter (17464): #18     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (17464): #19     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

The URL I use for the tile provider gives me this JSON (is this correct, is this the correct URL?):

code>{
  "tiles": [
    "/{z}/{x}/{y}/?token=XXX",
    "/{z}/{x}/{y}/?token=XXX",
    "/{z}/{x}/{y}/?token=XXX",
    "/{z}/{x}/{y}/?token=XXX"
  ],
  "attribution": "© viamap ApS © OpenStreetMap contributors",
  "description": "A tileset showcasing all layers provided by viamap.",
  "format": "pbf",
  "pixel_scale": "256",
  "minzoom": 0,
  "maxzoom": 16,
  "tilejson": "2.0.0",
  "id": "viavector",
  "name": "viavector",
  "vector_layers": [
    {
      "maxzoom": 16,
      "fields": {
        "class": "String"
      },
      "minzoom": 0,
      "id": "water",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "name:nonlatin": "String",
        "class": "String",
        "name": "String",
        "brunnel": "String",
        "name:latin": "String"
      },
      "minzoom": 0,
      "id": "waterway",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "class": "String",
        "subclass": "String"
      },
      "minzoom": 0,
      "id": "landcover",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "class": "String"
      },
      "minzoom": 0,
      "id": "landuse",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "name": "String",
        "name:nonlatin": "String",
        "name:latin": "String",
        "rank": "Number",
        "ele": "Number",
        "osm_id": "Number",
        "ele_ft": "Number"
      },
      "minzoom": 0,
      "id": "mountain_peak",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "class": "String"
      },
      "minzoom": 0,
      "id": "park",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "admin_level": "Number",
        "disputed": "Number",
        "maritime": "Number"
      },
      "minzoom": 0,
      "id": "boundary",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "ref": "String",
        "class": "String"
      },
      "minzoom": 0,
      "id": "aeroway",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "layer": "Number",
        "indoor": "Number",
        "service": "String",
        "oneway": "Number",
        "brunnel": "String",
        "level": "Number",
        "ramp": "Number",
        "class": "String",
        "subclass": "String"
      },
      "minzoom": 0,
      "id": "transportation",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "render_min_height": "Number",
        "render_height": "Number",
        "osm_id": "Number"
      },
      "minzoom": 0,
      "id": "building",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "name:nonlatin": "String",
        "class": "String",
        "name": "String",
        "name:latin": "String"
      },
      "minzoom": 0,
      "id": "water_name",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "layer": "Number",
        "name:nonlatin": "String",
        "indoor": "Number",
        "class": "String",
        "network": "String",
        "name": "String",
        "level": "Number",
        "ref_length": "Number",
        "subclass": "String",
        "name:latin": "String",
        "ref": "String"
      },
      "minzoom": 0,
      "id": "transportation_name",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "name": "String",
        "name:nonlatin": "String",
        "name:latin": "String",
        "rank": "Number",
        "capital": "Number",
        "iso_a2": "String",
        "class": "String"
      },
      "minzoom": 0,
      "id": "place",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "housenumber": "String"
      },
      "minzoom": 16,
      "id": "housenumber",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "name": "String",
        "name:nonlatin": "String",
        "subclass": "String",
        "rank": "Number",
        "name:latin": "String",
        "class": "String",
        "agg_stop": "Number"
      },
      "minzoom": 0,
      "id": "poi",
      "description": ""
    },
    {
      "maxzoom": 16,
      "fields": {
        "icao": "String",
        "iata": "String",
        "name": "String",
        "osm_id": "Number",
        "ele_ft": "Number",
        "name:nonlatin": "String",
        "name:latin": "String",
        "class": "String",
        "ele": "Number"
      },
      "minzoom": 0,
      "id": "aerodrome_label",
      "description": ""
    }
  ],
  "bounds": [
    -180,
    -89.9511,
    180,
    89.9511
  ],
  "version": "1.0",
  "type": "vector"
}

Any ideas on what I should try to move forward with this?

Thank you
Søren

本文标签: flutterInvalidProtocolBufferException when loading vector tilesStack Overflow