Skip to content
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

Can't re-set absolute path on image source #1358

Closed
Dawqss opened this issue May 20, 2021 · 3 comments
Closed

Can't re-set absolute path on image source #1358

Dawqss opened this issue May 20, 2021 · 3 comments
Labels
wontfix This will not be worked on

Comments

@Dawqss
Copy link

Dawqss commented May 20, 2021

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @react-native-mapbox-gl/maps@8.1.0 for the project I'm working on.

When you want to change to new URL with absolute path (RNFetchBlob) after second time it doesn't add file:// prefix to uri and it crashes

Here is the diff that solved my problem:

diff --git a/node_modules/@react-native-mapbox-gl/maps/ios/RCTMGL/RCTMGLImageSource.m b/node_modules/@react-native-mapbox-gl/maps/ios/RCTMGL/RCTMGLImageSource.m
index 817918b..cf1fe94 100644
--- a/node_modules/@react-native-mapbox-gl/maps/ios/RCTMGL/RCTMGLImageSource.m
+++ b/node_modules/@react-native-mapbox-gl/maps/ios/RCTMGL/RCTMGLImageSource.m
@@ -17,7 +17,19 @@ - (void)setUrl:(NSString *)url
 
     if (self.source != nil) {
         MGLImageSource *source = (MGLImageSource *)self.source;
-        source.URL = [NSURL URLWithString:_url];
+
+        NSURL *myURL;
+
+        if ([[_url substringToIndex:4] isEqualToString:@"http"]) {
+            myURL = [NSURL URLWithString:_url];
+        }
+        else {
+            //Default consider it file url path
+            myURL = [NSURL fileURLWithPath:_url];
+        }
+
+        source.URL = myURL;
+
     }
 }
 

This issue body was partially generated by patch-package.

@ferdicus
Copy link
Member

feel free to open a proper PR :)

@James-Firth
Copy link

@Dawqss I'm interested in this issue!
How are you setting your initial URL?
When I tried setting it file:// prefix isn't loading even the first time.
If I can get it to work I could test out your changes (though they look sensible to me from reading the source files).

@stale
Copy link

stale bot commented Apr 19, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Apr 19, 2022
@stale stale bot closed this as completed Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants