-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RCTMapboxGL should expose the underlying MGLMapView #334
Comments
I disagree. It helps with isolation. Especially since in #365 the |
If the intention is to essentially queue up property changes until MGLMapView exists, the current design makes some sense. But why not create MGLMapView when RCTMapboxGL is initialized, since there’s a one-to-one correspondence? An MGLMapView doesn’t have to be added to the view hierarchy immediately after being initialized. Regardless, methods such as - (void)setDebugActive:(BOOL)debugActive
{
_debugActive = debugActive;
if (_debugActive != debugActive) _map.debugActive = debugActive;
} There’s no need to check whether |
You're totally right. I thought this delayed load was done for a reason in the original implementation. This would simplify the code greatly. Though, are you sure it's not cheaper to initialise it only after we know the frame? What happens with the underlying OpenGL texture if we call Also, I knew that sending messages to |
There is a known issue with initializing the map view without a frame: mapbox/mapbox-gl-native#1572. I’ve been unable to reproduce it but apparently others keep running into it. The workaround is indeed to set an initial size like 10×10 and resize the view once you find out its eventual size. This is no different than what a native iOS application does when an Auto Layout–enabled view controller is set up, and it shouldn’t be any more expensive than loading the style in the first place. The only thing I’d watch out for is that RNMBGL, at least in its original implementation, had a habit of blowing away the map view and reconstructing it any time a property changed. That behavior could be expensive and wasteful, and you’d want to avoid it if it’s still the case. |
The no-op thing isn’t a huge deal. I’m sure you aren’t alone in preferring explicit checks. Relying on the no-op behavior is very common in Objective-C mainly because the language is so verbose, but there’s no technical advantage. The one case I’d watch out for is if you need to chain property accesses. For instance, (I don’t meant to insult your intelligence; just want to write down some of the things @bsudekum and I have discussed in the past regarding this codebase.) |
Ok. Then I guess the course of action would be to initialise That destroy-and-reconstruct behaviour has since been fixed in my PR. It was one of the main reasons I made the PR in the first place. It now changes properties on _map as props come in. |
Wonderful! Yes, subclassing MGLMapView would simplify things even further. |
All these methods and the corresponding implementations could go away if RCTMapboxGL’s
_map
ivar is replaced with a public MGLMapView-typedmapView
property (which could be accessed as a_mapView
ivar inside RCTMapboxGL). Then, any time you need to do something to the MGLMapView inside RCTMapboxGLManager, you can useview.mapView.someProperty
instead of having to implement yet anothersomeProperty
on RCTMapboxGL./cc @bsudekum
The text was updated successfully, but these errors were encountered: