Yermo / nativescript-mapbox

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

iOS setMapStyle() resolves promise immediately before the style has been loaded #302

Open Yermo opened 5 years ago

Yermo commented 5 years ago

When loading a remote style on the iOS side, setMapStyle() returns immediately before the style has a chance to load.

To fix this, I think this callback needs to be hooked (like it is on the Android side): https://docs.mapbox.com/ios/api/maps/4.9.0/Protocols/MGLMapViewDelegate.html#/c:objc(pl)MGLMapViewDelegate(im)mapView:didFinishLoadingStyle:

So I'm trying to implement this, but I don't yet understand how to hook this callback.

Any pointers to guide me in the right direction?

Yermo commented 5 years ago

Never mind. It looks like there's no entry for mapViewDidFinishLoadingStyle() in tns-platform-declarations but if you define the method in MLMapViewDelegateImpl() it does get called after setMapStyle is called.

Now to figure out why it gets called three times after the style is set.

Rajdeo-Das commented 4 years ago

How do we use this feature? I am trying to implement the below example. https://docs.mapbox.com/ios/maps/examples/image-source/

But can not find any documentation around this. Please help.