flet icon indicating copy to clipboard operation
flet copied to clipboard

fix: `MapConfiguration.interaction_configuration` is not honoured

Open ndonkoHenri opened this issue 1 year ago • 1 comments

Description

Fixes #3973

Summary by Sourcery

Fix the issue where MapConfiguration.interaction_configuration was not being honored by adding the interactionOptions to MapOptions. Enhance the map functionality by introducing support for pointer hover events, allowing the map to trigger a pointer_hover event with latitude, longitude, and pointer details.

Bug Fixes:

  • Ensure MapConfiguration.interaction_configuration is correctly applied by adding the interactionOptions parameter to MapOptions.

Enhancements:

  • Add support for handling pointer hover events on the map, triggering a pointer_hover event with relevant details.

ndonkoHenri avatar Sep 12 '24 23:09 ndonkoHenri

Reviewer's Guide by Sourcery

This pull request addresses an issue where the MapConfiguration.interaction_configuration was not being honored. The changes primarily involve refactoring and enhancing the map-related utility functions and the MapOptions configuration in the Flet map package.

File-Level Changes

Change Details Files
Refactored map utility functions to use 'j' instead of 'json' as parameter name
  • Changed parameter name from 'json' to 'j' in latLngFromJson, latLngBoundsFromJson, and strokePatternFromJson functions
  • Updated function bodies to use 'j' instead of 'json'
packages/flet_map/lib/src/utils/map.dart
Enhanced parseInteractionOptions and interactionOptionsFromJSON functions
  • Made parseInteractionOptions return nullable InteractionOptions
  • Added optional default value parameter to interactionOptionsFromJSON
  • Implemented null check in interactionOptionsFromJSON
packages/flet_map/lib/src/utils/map.dart
Updated MapOptions configuration in MapControl widget
  • Added interactionOptions to MapOptions using parseInteractionOptions
  • Implemented onPointerHover event handler
  • Added import for flutter/gestures.dart
packages/flet_map/lib/src/map.dart

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

sourcery-ai[bot] avatar Sep 12 '24 23:09 sourcery-ai[bot]

Can you look at conflicts please?

FeodorFitsner avatar Oct 29 '24 17:10 FeodorFitsner

Hi, I just installed Flet v0.25.0 Release but the problem is still present : MapConfiguration.interaction_configuration is not honoured. I tried these flags flags=map.MapInteractiveFlag.ALL & ~map.MapInteractiveFlag.ROTATE I tested on Windows 11. I also tried to test on IOS (iPad & iPhone), but Map doesn't display !!! I have to regress to Flet v0.24.1

Michel7GitHub avatar Nov 29 '24 16:11 Michel7GitHub

It works on my mac:

import random
import flet as ft
import flet.map as map


def main(page: ft.Page):

    page.add(
        map.Map(
            expand=True,
            initial_center=map.MapLatitudeLongitude(15, 10),
            initial_zoom=4.2,
            interaction_configuration=map.MapInteractionConfiguration(flags=map.MapInteractiveFlag.NONE),
            layers=[
                map.TileLayer(
                    url_template="https://tile.openstreetmap.org/{z}/{x}/{y}.png",
                    on_image_error=lambda e: print("TileLayer Error"),
                ),
            ],
        ),
    )


ft.app(main)

Give the above a try.

ndonkoHenri avatar Nov 29 '24 16:11 ndonkoHenri

Hi ndonkoHenri, I tried your code on Windows and all flags get OFF (this is OK) BUT the one I want OFF still ON ... Rotate Flag ! Did you try to Rotate on Mac? I tried your code on iPad (v0.24.1 app) and Windows 11 as server with v0.25.0... Map doesn't display. Should I update IOS App version ? I don't find new version on AppStore. I don't know if it's important, but I receive this message (show on my Windows 11 server) when I tried on IOS (iPad) : C:\Python312\Lib\site-packages\websockets\legacy\server.py:1177: DeprecationWarning: remove second argument of ws_handler warnings.warn("remove second argument of ws_handler", DeprecationWarning)

Michel7GitHub avatar Nov 29 '24 17:11 Michel7GitHub

Yes it works too:

interaction_configuration=map.MapInteractionConfiguration(flags=map.MapInteractiveFlag.ALL & ~map.MapInteractiveFlag.ROTATE)

Will give it a try on my Windows when possible.

Concerning the Flet app, we are working on updating it to support changes made in 0.25.0

ndonkoHenri avatar Nov 29 '24 17:11 ndonkoHenri