liodali / osm_flutter

OpenStreetMap plugin for flutter
https://pub.dev/packages/flutter_osm_plugin
MIT License
239 stars 98 forks source link

Bug in map zoom more than 17 step IOS #543

Closed gopelkujo closed 3 months ago

gopelkujo commented 4 months ago

Problem The bug occurred when I zoomed in at step 18 onwards. This bug only happen in IOS, i tested on Iphone 15 Pro Max (IOS 17.5) and Iphone 11 (IOS 16.4). In Android it's all good.

Demonstration

https://github.com/user-attachments/assets/3204b0af-00c3-4040-aa0e-60e64e91ed01

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-ID)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.91.1)
[✓] Connected device (6 available)
    ! Error: Browsing on the local area network for Rifa Fauziah W. Ensure the device is unlocked and attached with a cable or associated
      with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

• No issues found!

\ Minimal Code To Reproduce

import 'dart:io';

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  MapController mapController = MapController(
    initPosition: GeoPoint(latitude: 47.4358055, longitude: 8.4737324),
    areaLimit: BoundingBox(
      east: 10.4922941,
      north: 47.8084648,
      south: 45.817995,
      west: 5.9559113,
    ),
  );

  @override
  void dispose() {
    mapController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: SafeArea(
        bottom: Platform.isAndroid,
        child: Stack(
          alignment: Alignment.bottomCenter,
          children: [
            Center(
              child: OSMFlutter(
                controller: mapController,
                osmOption: OSMOption(
                  zoomOption: const ZoomOption(
                    initZoom: 18,
                    minZoomLevel: 3,
                    maxZoomLevel: 19,
                    stepZoom: 1.0,
                  ),
                  userLocationMarker: UserLocationMaker(
                    personMarker: const MarkerIcon(
                      icon: Icon(
                        Icons.location_history_rounded,
                        color: Colors.red,
                        size: 48,
                      ),
                    ),
                    directionArrowMarker: const MarkerIcon(
                      icon: Icon(
                        Icons.double_arrow,
                        size: 48,
                      ),
                    ),
                  ),
                  roadConfiguration: const RoadOption(
                    roadColor: Colors.yellowAccent,
                  ),
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(32),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                  IconButton.filled(
                    onPressed: mapController.zoomIn,
                    icon: const Icon(Icons.zoom_in_rounded),
                  ),
                  IconButton.filled(
                    onPressed: mapController.zoomOut,
                    icon: const Icon(Icons.zoom_out_rounded),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
liodali commented 4 months ago

yeah im aware of the issue i will focus on it this days to fix it

gopelkujo commented 4 months ago

Thanks for your response! hope soon i can contribute to this package🚀

liodali commented 3 months ago

HI again In your ios folder run pod update I updated our ios sdk so i think the issue is solved

gopelkujo commented 3 months ago

Hi! i already tested on IOS 17.5 (iPhone 15 Pro Max) & IOS 16.4 (iPhone 8 Plus) and it's work like a charm🚀

Thanks for your effort, i close this issue as the issue already resolved.