maplibre / flutter-maplibre-gl

Customizable, performant and vendor-free vector and raster maps, flutter wrapper for maplibre-native and maplibre-gl-js (fork of flutter-mapbox-gl/maps)
https://pub.dev/packages/maplibre_gl
Other
186 stars 106 forks source link

[BUG] Unable to Render Higher Zoom Levels with Overzooming #418

Closed baurzhan closed 1 month ago

baurzhan commented 1 month ago

Platforms

all

Version of flutter maplibre_gl

master branch

Bug Description

I am using the flutter_maplibre_gl package to render vector tiles from an MBTiles file. The MBTiles file has a maximum zoom level of 14. However, I need to render higher zoom levels (up to zoom level 22) using overzooming. Despite setting the minMaxZoomPreference property, the map does not render tiles at higher zoom levels beyond 14.

Steps to Reproduce

  1. Set up a tile server using tileserver-gl to serve the MBTiles file.
  2. Configure the flutter_maplibre_gl package in a Flutter application to load the tiles from the tile server.
  3. Set the minMaxZoomPreference property to allow zoom levels from 0 to 22.

Expected Results

The map should render tiles at zoom levels higher than 14 by overzooming the available tiles from the maximum zoom level (14).

Actual Results

The map stops rendering tiles at zoom level 14 and does not display any tiles for zoom levels higher than 14.

Code Sample

import 'package:flutter/material.dart';
import 'package:maplibre_gl/maplibre_gl.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Maplibre GL Example'),
        ),
        body: MaplibreMapWidget(),
      ),
    );
  }
}

class MaplibreMapWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaplibreMap(
      initialCameraPosition: const CameraPosition(
        target: LatLng(37.7749, -122.4194), // San Francisco
        zoom: 14.0,
      ),
      styleString: 'http://localhost:8080/styles/basic/style.json', // URL to the local tile server
      minMaxZoomPreference: const MinMaxZoomPreference(0, 22), // Set the zoom range from 0 to 22
    );
  }
}

Tile Server Configuration: I am using tileserver-gl with the following configuration:

docker run -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl

The style.json file used by the tile server:

{
  "version": 8,
  "sources": {
    "your_source": {
      "type": "vector",
      "url": "mbtiles://{your_mbtiles_file}",
      "minzoom": 0,
      "maxzoom": 14
    }
  },
  "layers": [
    {
      "id": "your_layer",
      "type": "fill",
      "source": "your_source",
      "source-layer": "your_layer",
      "minzoom": 0,
      "maxzoom": 22 // Set to allow overzooming
    }
  ]
}
ZoroLH commented 1 week ago

Any update on this? without overzoom feature, the mbtiles will be super large by adding unnecessary data.

josxha commented 1 week ago

Overzooming is already possible. I assume the problem here was a missing maxZoom property in the style json but I can't be certain about it without having seen it. The issue was closed on the same day by the author so there won't be any further investigation on it.