osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

Display error userLocationMarker

Open DmitriySimonov opened this issue 1 year ago • 12 comments

flutter_osm_plugin: ^1.0.0-dev.4

The icon on the IOS phone is huge and an error appears in the logs. Everything is fine on Android phones.

[ERROR:flutter/runtime/dart_vm_[initializer.cc](http://initializer.cc/)(41)] Unhandled Exception: Exception: Error to draw you custom icon
#0 MethodChannelOSM._capturePng (package:flutter_osm_interface/src/channel/osm_method_channel.dart:326:7)
#1 MethodChannelOSM.addMarker (package:flutter_osm_interface/src/channel/osm_method_channel.dart:499:24)
#2 MobileOSMController.addMarker.<anonymous closure> (package:flutter_osm_plugin/src/controller/osm/osm_controller.dart:402:27)
#3 new Future.delayed.<anonymous closure> (dart:async/future.dart:427:39)
#4 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#5 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
#6 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
#7 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

Code:

          OSMFlutter(
            osmOption: OSMOption(
              userLocationMarker: UserLocationMaker(
                personMarker: MarkerIcon(
                  assetMarker: AssetMarker(
                    image: const AssetImage(Const.ICON_MAP_MARKER_PERSON),
                    scaleAssetImage: 0.6,
                  ),
                ),
                directionArrowMarker: MarkerIcon(
                  assetMarker: AssetMarker(
                    image: const AssetImage(Const.ICON_MAP_MARKER_PERSON_DIRECTED),
                    scaleAssetImage: 0.6,
                  ),
                ),
              ),
            ),
          ),

icons: icon_marker_person icon_marker_person_directed

Screen: изображение

flutter doctor:

[✓] Flutter (Channel stable, 3.16.9, on Ubuntu 22.04.3 LTS 5.15.0-92-generic, locale ru_RU.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2023.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2)
[✓] Connected device (3 available)
[✓] Network resources

DmitriySimonov avatar Feb 09 '24 12:02 DmitriySimonov

try to put your userLocation Marker inside SizedBox and give them small size

liodali avatar Feb 09 '24 13:02 liodali

@DmitriySimonov you didnt like my suggestion ? did you overcome the issue ? or you need some fixes from our side ?

liodali avatar Feb 29 '24 08:02 liodali

i will work on this try to make quick fix for it sorry for any late

liodali avatar Feb 29 '24 08:02 liodali

try to put your userLocation Marker inside SizedBox and give them small size

That didn't help, and the error remained

DmitriySimonov avatar Feb 29 '24 08:02 DmitriySimonov

i will try to do fix for that

liodali avatar Feb 29 '24 09:02 liodali

small question is the icon marker shown ok for you the only issue is userLocation icon ?

liodali avatar Feb 29 '24 10:02 liodali

small question is the icon marker shown ok for you the only issue is userLocation icon ?

Yes

I tried rewriting the code this way and it helped, the display userLocation became normal.

But the error in the console remains

              userLocationMarker: UserLocationMaker(
                personMarker: MarkerIcon(
                  iconWidget: Image.asset(
                    Const.ICON_MAP_MARKER_PERSON,
                    width: 100,
                    height: 100,
                  ),
                ),
                directionArrowMarker: MarkerIcon(
                  iconWidget: Image.asset(
                    Const.ICON_MAP_MARKER_PERSON_DIRECTED,
                    width: 100,
                    height: 100,
                  ),
                ),
              ),

DmitriySimonov avatar Feb 29 '24 11:02 DmitriySimonov

you need to show us more of your code where you're using addMarker? and the issue of userLocation we will solved also

liodali avatar Feb 29 '24 13:02 liodali

you need to show us more of your code where you're using addMarker? and the issue of userLocation we will solved also

      final MarkerIcon icon = MarkerIcon(
        iconWidget: SvgPicture.asset(
          Const.ICON_MAP_MARKER_LOAD_SVG,
          height: 30,
        ),
      );
      await mapController.addMarker(
        GeoPoint(latitude: 0.0, longitude: 0.0),
        markerIcon: icon,
        iconAnchor: IconAnchor(anchor: Anchor.top),
      );

DmitriySimonov avatar Feb 29 '24 13:02 DmitriySimonov

ah you're using svg as icon ok give me sometime to do some verification and maybe i need to add some sepecific api in MarkerIcon to make svg render more smooth if the display of userlocation is normal keep that fix and share with me to see how i can adjust my ios side with it and i will do quick fix for svg side

liodali avatar Feb 29 '24 14:02 liodali

@DmitriySimonov for use case try to add width also in SvgPicture.asset

liodali avatar Mar 01 '24 11:03 liodali

Unfortunately I can't do that right now, no access to IOS, and won't be for a long time(

DmitriySimonov avatar Mar 01 '24 11:03 DmitriySimonov