Yermo / nativescript-mapbox

:statue_of_liberty: :tokyo_tower: :mount_fuji: Native OpenGL powered Maps, by Mapbox
MIT License
194 stars 94 forks source link

setMapStyle and removeOnDidFailLoadingMapListener #393

Open amlibtest opened 4 years ago

amlibtest commented 4 years ago

Hello, I recently migrated an application (with angular) to nativescript 6.8.0 and updated the mapbox plugin to version 5.0.1. However, when I try to call setMapStyle function using a JSON file from my app I get the following error

Unhandled Promise rejection: loading style failed: Could not read asset ; Zone: <root> ; Task: Promise.then ; Value: loading style failed: Could not read asset undefined

Note that this code used to work correctly back in nativescript 5, so there shouldn't be any mistake from my JSON file or its path (~/maps/custom.json)

Also, when going back from a component while using Android, this error is shown on console:

Unhandled Promise rejection: Cannot read property 'removeOnDidFailLoadingMapListener' of null ; Zone: <root> ; Task: setTimeout ; Value: TypeError: Cannot read property 'removeOnDidFailLoadingMapListener' of null TypeError: Cannot read property 'removeOnDidFailLoadingMapListener' of null

I have to add that I always call destroy before leaving or pausing the component. I've seen it's the only way to avoid creating multiple maps in the previous version, besides the fact that it will make the map to get loaded again on resume instead of showing a black screen