liodali / osm_flutter

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

Display error userLocationMarker #503

Open DmitriySimonov opened 9 months ago

DmitriySimonov commented 9 months ago

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
liodali commented 9 months ago

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

liodali commented 8 months ago

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

liodali commented 8 months ago

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

DmitriySimonov commented 8 months ago

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

That didn't help, and the error remained

liodali commented 8 months ago

i will try to do fix for that

liodali commented 8 months ago

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

DmitriySimonov commented 8 months ago

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,
                  ),
                ),
              ),
liodali commented 8 months ago

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

DmitriySimonov commented 8 months ago

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),
      );
liodali commented 8 months ago

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 commented 8 months ago

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

DmitriySimonov commented 8 months ago

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