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] initialCameraPosition argument ignores targets' latitude #407

Closed baurzhan closed 1 month ago

baurzhan commented 1 month ago

Description: When using the flutter_maplibre_gl package to set the initial camera position, the specified latitude value for the target location appears to be ignored. Regardless of the latitude value provided, the map centers incorrectly, which affects the initial view of the map.

Steps to Reproduce:

  1. Create a new Flutter application.
  2. Add the flutter_maplibre_gl package to pubspec.yaml.
  3. Configure the MaplibreMap widget with an initialCameraPosition specifying a target latitude.
  4. Run the application and observe the map's initial center.

Expected Behavior: The map should center on the specified target latitude provided in the initialCameraPosition argument.

Actual Behavior: The map ignores the target latitude and centers incorrectly, displaying a different initial location.

Code Example:

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 Latitude Issue'),
        ),
        body: MaplibreMapWidget(),
      ),
    );
  }
}

class MaplibreMapWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaplibreMap(
      initialCameraPosition: const CameraPosition(
        target: const LatLng(43.256900680871915, 76.90517963197661),
        zoom: 14.0,
      ),
      styleString: 'mapbox://styles/mapbox/streets-v11', // Example style
    );
  }
}

Environment:

Additional Context: The issue persists regardless of the latitude value provided. The map consistently centers on an incorrect location, indicating that the latitude value might be ignored or overwritten.