osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

What causes the map to black out?

Open mor7348 opened this issue 3 years ago • 24 comments

My program blacked out the map, so I tried it with '/example/lib/src/home/home_example.dart' and it looks the same. Do you know the cause?

Simulator Screen Shot - iPhone 11 Pro Max - 2022-02-01 at 11 50 43

mor7348 avatar Feb 01 '22 02:02 mor7348

that problem in rendering engine in map sdk i will check it

liodali avatar Feb 01 '22 07:02 liodali

are you still facing the same problem? because i tested and i didn't face black screen

liodali avatar Feb 03 '22 11:02 liodali

Sorry for the late reply.

The map blackout is still going on.

I got the following error and fixed it manually.

~~ / development / flutter / .pub-cache / hosted / pub.dartlang.org/flutter_osm_plugin-0.29.1+3/ios/Classes/Extension.swift: 225: 37: error: binary operator'-' cannot be applied to operands of type'Double' and'CGFloat' let size = CGPoint (x: width-(rect.minX --rect.maxX), y: height-(rect.minY --rect.maxY))

⇒let size = CGPoint (x: CGFloat (width)-(rect.minX --rect.maxX), y: CGFloat (height)-(rect.minY --rect.maxY))

~~/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.29.1+3/ios/Classes/MyMapView.swift:782:100: error: cannot convert value of type 'CGFloat' to expected argument type 'Double' let bounding = mapView.getBounds(width: mainView.bounds.width, height: mainView.bounds.height)

⇒let bounding = mapView.getBounds(width: Double(mainView.bounds.width), height: Double(mainView.bounds.height))

Is this the cause?

mor7348 avatar Feb 07 '22 12:02 mor7348

ok i will fix that

liodali avatar Feb 07 '22 12:02 liodali

if you're working on mac, you can overcome the problem temporary by open your project on XCode and in Pods folder try to find MyMapView.swift inside of flutter_osm_plugin folder and switch this line

let bounding = mapView.getBounds(width: mainView.bounds.width, height: mainView.bounds.height)

to

let bounding = mapView.getBounds(width: Double(mainView.bounds.width), height: Double(mainView.bounds.height))

rebuild the project

liodali avatar Feb 07 '22 13:02 liodali

thank you. I will try it.

mor7348 avatar Feb 07 '22 14:02 mor7348

I get an error in two places, and if I change it as follows, no error appears.

let size = CGPoint (x: width-(rect.minX --rect.maxX), y: height-(rect.minY --rect.maxY)) ⇒let size = CGPoint (x: CGFloat (width)-(rect.minX --rect.maxX), y: CGFloat (height)-(rect.minY --rect.maxY))

let bounding = mapView.getBounds(width: mainView.bounds.width, height: mainView.bounds.height) ⇒let bounding = mapView.getBounds(width: Double(mainView.bounds.width), height: Double(mainView.bounds.height))

However, the map has been blacked out.

Flutter 2.8.1 Dart 2.15.1 Xcode 12.5.1

Thank you.

mor7348 avatar Feb 07 '22 15:02 mor7348

when you do that, the map return working normally or you face another problem ?

liodali avatar Feb 07 '22 15:02 liodali

The problem hasn't changed. The controller is working and it seems that only the map part is not displayed.

controller.setMarkerIcon controller.centerMap controller.removeMarker etc ... These are working.

mor7348 avatar Feb 08 '22 02:02 mor7348

Simulator Screen Shot - iPhone 11 Pro Max - 2022-02-08 at 11 06 15

mor7348 avatar Feb 08 '22 02:02 mor7348

Sorry for the late reply, I want you to open your project with XCode and search in pods folder for flutter_osm_plugin try to find the file MyMapView and uncommend the lines 98 and 99 and comment the lines 100 and 100 and after that run your application and told me if the map shows or not

liodali avatar Feb 10 '22 10:02 liodali

Thanks for your comment. Uncommented lines 98,99 and commented out lines 97,100.

The map is working. Do you know the cause of the blackout?

mor7348 avatar Feb 11 '22 15:02 mor7348

i think the problem is related to style file that i'm using to customize the map and render the raster tile because that sdk can render vector tile also. so i need to make style file can be reach over the internet and maybe theengine faced a problem to access to it because i using shared file in dropbox :disappointed_relieved:

try to return it back like it was before the changes and told me it return black screen or still working

liodali avatar Feb 11 '22 16:02 liodali

I commented out and uncommented back. After all, the map will be blacked out.

image_iphone

mor7348 avatar Feb 12 '22 02:02 mor7348

keep the way where the map is working i will find another solution for raster tile i will published in next version

liodali avatar Feb 12 '22 08:02 liodali

Thank you very much. waiting for the next version.

mor7348 avatar Feb 12 '22 12:02 mor7348

if you can test this demo in appetize and see if the map working https://appetize.io/embed/the9m0c2mz7pm9j0ex67h8jh00?device=iphonex&osVersion=15.0&scale=75 because i made multiple test it with old way because i tried to used local asset in ios but it didn't work just told if it work with that line and also can you run pod update in terminal in ios folder and try to uncomment the previous lines (97,100) and build the application I want just to make sure that you are using the last sdks in ios and told me if the black screen still exist after

liodali avatar Feb 13 '22 11:02 liodali

Sorry for too late reply. I have connected and debugged the actual iPhone, but the map does not show up. (IOS15.2) I don't know about appetize as I have never tried it, but I will try it.

Since I can't confirm the display on IOS, I had been developing on Android. (Run on Android emulator)

The app shuts down as shown below, do you know why? (This situation happened suddenly)


I/OsmDroid( 4338): Using tile source: Mapnik I/OsmDroid( 4338): Tile cache increased from 0 to 9 E/osm ( 4338): osm flutter plugin create E/osm ( 4338): osm flutter plugin start E/osm ( 4338): osm flutter plugin resume E/BufferQueueProducer( 4338): SurfaceTexture-0-4338-1 dequeueBuffer: BufferQueue has been abandoned E/AndroidRuntime( 4338): FATAL EXCEPTION: main E/AndroidRuntime( 4338): Process: com.---.app PID: 4338 E/AndroidRuntime( 4338): java.lang.NullPointerException: Attempt to invoke virtual method 'org.osmdroid.views.MapViewRepository org.osmdroid.views.MapView.getRepository()' on a null object reference E/AndroidRuntime( 4338): at org.osmdroid.views.overlay.infowindow.InfoWindow.(InfoWindow.java:53) E/AndroidRuntime( 4338): at org.osmdroid.views.overlay.infowindow.BasicInfoWindow.(BasicInfoWindow.java:54) E/AndroidRuntime( 4338): at org.osmdroid.views.overlay.infowindow.MarkerInfoWindow.(MarkerInfoWindow.java:41) E/AndroidRuntime( 4338): at org.osmdroid.views.MapViewRepository.getDefaultMarkerInfoWindow(MapViewRepository.java:55) E/AndroidRuntime( 4338): at org.osmdroid.views.overlay.Marker.(Marker.java:116) E/AndroidRuntime( 4338): at org.osmdroid.views.overlay.Marker.(Marker.java:93) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.models.FlutterMarker.(FlutterMaker.kt:24) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.models.FlutterMarker.(FlutterMaker.kt:60) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.FlutterOsmView.createMarker(FlutterOsmView.kt:805) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.FlutterOsmView.createMarker$default(FlutterOsmView.kt:804) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.FlutterOsmView.addMarker(FlutterOsmView.kt:736) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.FlutterOsmView.addMarker$default(FlutterOsmView.kt:731) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.FlutterOsmView$setCacheMap$1$invokeSuspend$$inlined$forEach$lambda$1.invokeSuspend(FlutterOsmView.kt:587) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.FlutterOsmView$setCacheMap$1$invokeSuspend$$inlined$forEach$lambda$1.invoke(Unknown Source:10) E/AndroidRuntime( 4338): at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89) E/AndroidRuntime( 4338): at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165) E/AndroidRuntime( 4338): at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.FlutterOsmView$setCacheMap$1.invokeSuspend(FlutterOsmView.kt:586) E/AndroidRuntime( 4338): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) E/AndroidRuntime( 4338): at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:377) E/AndroidRuntime( 4338): at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30) E/AndroidRuntime( 4338): at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:25) E/AndroidRuntime( 4338): at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:110) E/AndroidRuntime( 4338): at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126) E/AndroidRuntime( 4338): at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56) E/AndroidRuntime( 4338): at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1) E/AndroidRuntime( 4338): at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47) E/AndroidRuntime( 4338): at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.FlutterOsmView.setCacheMap(FlutterOsmView.kt:582) E/AndroidRuntime( 4338): at hamza.dali.flutter_osm_plugin.FlutterOsmView.onMethodCall(FlutterOsmView.kt:329) E/AndroidRuntime( 4338): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) E/AndroidRuntime( 4338): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178) E/AndroidRuntime( 4338): at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:206) E/AndroidRuntime( 4338): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/AndroidRuntime( 4338): at android.os.Handler.handleCallback(Handler.java:938) E/AndroidRuntime( 4338): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 4338): at android.os.Looper.loop(Looper.java:223) E/AndroidRuntime( 4338): at android.app.ActivityThread.main(ActivityThread.java:7656) E/AndroidRuntime( 4338): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 4338): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/AndroidRuntime( 4338): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) I/Process ( 4338): Sending signal. PID: 4338 SIG: 9 Lost connection to device.

mor7348 avatar Feb 22 '22 01:02 mor7348

Connected iphone (IOS15.2), the emulator showed the map. I haven't figured out why yet, but I'm glad anyway. I'm going to proceed with the development.

mor7348 avatar Feb 22 '22 02:02 mor7348

what is the version that you're using ? and can you share small sample to understand you use case more and i will try to look deep into the log

liodali avatar Feb 22 '22 07:02 liodali

Hey I have the same problem running on iOS version 13.7 on an iPad. the screen is blacked out. Do I still need to uncomment the lines as you have described above ? seems to work fine in newer version of iOS above 14. however it did work the first time, now it keeps giving black screen.

jesussmile avatar Aug 04 '22 11:08 jesussmile

// let sceneUpdates = [TGSceneUpdate]()
             let sceneUpdates = [TGSceneUpdate(path: "global.sdk_api_key", value: "qJz9K05vRu6u_tK8H3LmzQ")]
             let sceneUrl = URL(string: "https://www.nextzen.org/carto/bubble-wrap-style/9/bubble-wrap-style.zip")!
            //let sceneUrl = URL(string: //"https://dl.dropboxusercontent.com/s/25jzvtghx0ac2rk/osm-style.zip?dl=0")!
            mapView.loadSceneAsync(from: sceneUrl, with: sceneUpdates)

Anyways uncommenting and commenting helped. by the way it now shows a better map style with 3D buildings, how can I enable this in android ?

jesussmile avatar Aug 04 '22 11:08 jesussmile

in android using another sdk but im planning to add that also for android and for blackscreen because style file maybe not downloaded maybe dropbix blocking access i will check it and i will try to fix that for all sorry for that

liodali avatar Aug 04 '22 13:08 liodali

try the ney version now, i changed the location of styles

liodali avatar Aug 08 '22 18:08 liodali