-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Added MBTiles support for iOS and Android #2208
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! Glad you got it to work. I had a few questions about certain things, hope you can inform me.
// | ||
|
||
#import "AIRMapMbTileOverlay.h" | ||
#import "FMDatabase.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm not too familiar with ios, but isn't there an included sqlite lib? Can you explain the rationale of including a large library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FMDB library is not that large - 173KB in total. It makes working with SQLite
way simpler and compared to the native SQLite3
only a few lines of code are needed. The native SQLite3
lib is sort of a raw library which makes it hard to use. One needs a lot of lines of code to achieve what can be achieved with the FMDB
library with only a few lines. Further, I have the feeling that the FMDB
database is the standard when it comes to SQLite
access on iOS: Rewriting it to SQLite3
would make it harder for other collaborators to maintain and extend the code. Just look at the online ressources around FMDB
and SQLite3
. I think it is better to stick with FMDB
. Rewriting to SQLite3
would make the code overly complicated and less maintainable. Maintainability and extenability is in my opinion more important on a community based project than adding 173KB of size to the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, can someone with more iOS experience than I do comment?
[query replaceCharactersInRange: [query rangeOfString: @"{x}"] withString:[NSString stringWithFormat:@"%li", path.x]]; | ||
[query replaceCharactersInRange: [query rangeOfString: @"{y}"] withString:[NSString stringWithFormat:@"%li", path.y]]; | ||
FMResultSet *databaseResult = [offlineDataDatabase executeQuery:query]; | ||
if ([databaseResult next]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider the following (may contain syntax errors since I'm not familiar with this language)
NSData *tile = nil
if ([databaseResult next]) {
tile = [databaseResult dataForColumn:@"tile_data"];
}
[offlineDataDatabase close];
result(tile,nil);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't change that due to code consistency. Look at
which is the template for my feature. I think consistency is better here. Thus I will stick with
if ([databaseResult next]) {
NSData *tile = [databaseResult dataForColumn:@"tile_data"];
[offlineDataDatabase close];
result(tile,nil);
} else {
[offlineDataDatabase close];
result(nil,nil);
}
} | ||
offlineDataDatabase.close(); | ||
return null; | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe catching a generic exception like this might lead to some bugs. In general, it is better to be specific about your exceptions when you know they exist, like this.
Consider the following:
- You open a connection successfully, but your string replace (currently line line 55) throws an error. I believe you will end up not closing the database.
I would look into other code that uses this lib and see how they do error handling, but on very cursory glance, I would structure it like the following:
try {
SQLiteDatabase offlineDataDatabase offlineDataDatabase = SQLiteDatabase.openDatabase(this.pathTemplate, null, SQLiteDatabase.OPEN_READONLY);
String query = rawQuery.replace("{x}", Integer.toString(x)).replace("{y}", Integer.toString(y))
.replace("{z}", Integer.toString(zoom));
Cursor cursor = offlineDataDatabase.rawQuery(query, null);
byte[] tile = null
if(cursor.moveToFirst()) {
tile = cursor.getBlob(5);
cursor.close();
}
offlineDataDatabase.close();
return tile;
} catch (SQLiteCantOpenDatabaseException e) {
// error handle, this case is when database can't open so return null?
} catch (android.database.sqlite.SQLiteException e) {
// error handle, past an open database connection so close and return null.
} catch (Exception e) {
// all other cases, return null?
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly even better:
byte[] tile = null
try {
SQLiteDatabase offlineDataDatabase offlineDataDatabase = SQLiteDatabase.openDatabase(this.pathTemplate, null, SQLiteDatabase.OPEN_READONLY);
String query = rawQuery.replace("{x}", Integer.toString(x)).replace("{y}", Integer.toString(y))
.replace("{z}", Integer.toString(zoom));
Cursor cursor = offlineDataDatabase.rawQuery(query, null);
if(cursor.moveToFirst()) {
tile = cursor.getBlob(5);
cursor.close();
}
offlineDataDatabase.close();
} catch (SQLiteCantOpenDatabaseException e) {
// error handle, this case is when database can't open so return null?
} catch (android.database.sqlite.SQLiteException e) {
// error handle, past an open database connection so close and return null.
} catch (Exception e) {
// all other cases, return null?
}
return tile;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out. I changed the "closing the database" problem and included some catch
. I prefer the code written slightly different, so I left that. I included a more elaborated error handling namely SQLiteCantOpenDatabaseException
, SQLiteDatabaseCorruptException
and SQLiteDatabaseLockedException
.
byte[] tile = null;
try {
SQLiteDatabase offlineDataDatabase = SQLiteDatabase.openDatabase(this.pathTemplate, null, SQLiteDatabase.OPEN_READONLY);
String query = rawQuery.replace("{x}", Integer.toString(x))
.replace("{y}", Integer.toString(y))
.replace("{z}", Integer.toString(zoom));
Cursor cursor = offlineDataDatabase.rawQuery(query, null);
if (cursor.moveToFirst()) {
tile = cursor.getBlob(5);
}
cursor.close();
offlineDataDatabase.close();
} catch (SQLiteCantOpenDatabaseException e) {
e.printStackTrace();
throw e;
} catch (SQLiteDatabaseCorruptException e) {
e.printStackTrace();
throw e;
} catch (SQLiteDatabaseLockedException e) {
e.printStackTrace();
throw e;
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
return tile;
}
if(cursor.moveToFirst()){ | ||
byte[] tile = cursor.getBlob(5); | ||
cursor.close(); | ||
offlineDataDatabase.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal preference is to consolidate all cleanup and return into one section to prevent future bugs, see code snippet below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to which makes more sense to me.
if (cursor.moveToFirst()) {
tile = cursor.getBlob(5);
}
cursor.close();
offlineDataDatabase.close();
return tile;
.replace("{y}", Integer.toString(y)) | ||
.replace("{z}", Integer.toString(zoom)); | ||
Cursor cursor = offlineDataDatabase.rawQuery(query, null); | ||
if(cursor.moveToFirst()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace between )
and {
, 'if' and '('.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added whitespaces.
if (cursor.moveToFirst()) {
tile = cursor.getBlob(5);
}
|
||
|
||
-(void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result { | ||
FMDatabase *offlineDataDatabase = [FMDatabase databaseWithPath:self.URLTemplate]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this function need error handling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SQLite does not return execptions, only an error code for which one can check. I added a check if a file exists at the given path.
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:self.URLTemplate]) {
FMDatabase *offlineDataDatabase = [FMDatabase databaseWithPath:self.URLTemplate];
[offlineDataDatabase open];
....
} else {
NSLog(@"Database not found. Wrong path");
}
``
} | ||
offlineDataDatabase.close(); | ||
return null; | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, what appears for the tile in this case? Is it blank? I see https://github.com/react-community/react-native-maps/blob/f1126a4f307084005f7b62b0dc50fbfcfc810cd4/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTile.java#L62 does it too so I assume it's standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, should be blank. iOS and Android.
I won't have time the next ~two weeks to look into this. Using |
No worries at all, I would love to help more if I can, but not sure if I can be that helpful implementation wise. I won't be needing this for a few weeks myself, but when the time comes I will definitely be more proactive about getting something like this out. Whom should we talk to to also review this? |
@Stophface Any updates on timetables? No rush, just wanted a heads up. In 2 or so weeks I'll have to start pushing this along and fork my own repo if I have to--would highly prefer to not because It'll take me a lot longer to pick up on the native code. Do we have any one else to code review too to get this moving along? |
@h3ll0w0rld123 I think in around two weeks I have time to look into this. Maybe a few days earlier. Pretty much snowed in with work at the moment. It works though, so you can use it :) |
Good to know @Stophface, but I'll need any code to be merged into the mainline before using it. I'm also using Expo, so it takes them a while to accept the new changes as well, which is why I wanted to get this moving. Do you know who reviews PR for this project that we can tag? |
@rborn @zavadpe @alvelig Since you guys were involved with #1876 do you mind taking a look at this PR and let @Stophface and me know if there needs to be any changes? |
@zavadpe 🐽 |
🙏 Get this in please |
@terribleben Is another name to tag |
@Stophface have you gotten more time to look at this? |
@Stophface Sorry, been busy last couple of weeks. From a brief look I took it looks quite fine. I would consider notes from @h3ll0w0rld123 and you've got some conflicts to solve. I can take a deeper look then. |
@zavadpe Yeah the notes from @h3ll0w0rld123 are valuable. I might be able to look into it on the weekend. |
@Stophface Conflicts must be resolved in your fork repository.. |
I commented on all the comments of @h3ll0w0rld123 and inserted the changes into my code as written in the comments (@alvelig, @ahmetabdi). I am working on resolving the merge conflicts @zavadpe. |
…ib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java and index.d.ts
Inclduded the component in the Readme
…native-maps into feature/mbtiles Added Readme
@h3ll0w0rld123, @alvelig, @ahmetabdi, @zavadpe, @mlc I added the changes, resolved the merge conflicts. I also extended the If everyone is happy with my changes (see comments on @h3ll0w0rld123 suggestions) and the merge conflicts are properly solved, someone should merge it?! |
@Stophface looks like your travis ci build has some errors, looks like it's a linter problem. Anyone else can review this? |
@Stophface any chance to fix this? I'll try to revert the merge |
Ok, looks like it worked. |
@rborn Not sure how to fix this. Did you remove the line?! I am positive that I did not touch any imports in I can add the import though if that helps... |
@rborn haha yes, that definitly is a word ;) I added the line and pushed it. Do I need to make a new PR?! Itis not showing here. Its online though: https://github.com/Stophface/react-native-maps/commit/e1296bb3b6ad975ecc5e453286edce2bc5180f06 |
@Stophface I believe yes |
* master: (168 commits) Adding overlaying components details (react-native-maps#2425) docs: pin color limitations for android (react-native-maps#2429) Revert "Added MBTiles support for iOS and Android (react-native-maps#2208)" (react-native-maps#2387) Added MBTiles support for iOS and Android (react-native-maps#2208) Fix disabling the toolbar and my location button (react-native-maps#2317) Fixes warnings about self (react-native-maps#2341) Android: Fix lineCap of Polyline (react-native-maps#2375) Update installation.md (react-native-maps#2381) update doc (react-native-maps#2363) zIndex doesn't work when the map moves in iOS 11 (react-native-maps#2359) Fix readme formatting (react-native-maps#2358) add support for calloutAnchor with GoogleMaps on iOS; fixes react-native-maps#1852 (react-native-maps#2351) Added animateToNavigation method to MapView (react-native-maps#2049) Add react-native@^0.55 to peerDependencies (react-native-maps#2332) Fix custom marker updates on android react-native-maps#1611 react-native-maps#2048 [iOS] Prefix or eliminate globals in AIRMapMarker (react-native-maps#2306) Fix CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF warnings (react-native-maps#2154) Fix for compile error (react-native-maps#2215). (react-native-maps#2232) Make tiles display at the same physical size regardless of pixel dens… (react-native-maps#2248) Added support of lineDashPattern polyline prop to iOS Google Maps (react-native-maps#2243) ... # Conflicts: # lib/components/MapMarker.js
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
…2208)" (react-native-maps#2387) This reverts commit 2d760e1.
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
* Added MBTiles support for iOS and Android * Added changes regarding the comments of @h3ll0w0rld123 from here: react-native-maps/react-native-maps#2208 (comment) * Added whitespaces * Hotfix: Imported exceptions. Changed database.close() * Hotfix: Removed the finally statemend. Resulted in always returning null * Removed repetition of returns. Moved everything into finally statement instead * Throwing exceptions * Added MapView.MbTile to Readme. Inclduded the component in the Readme * Added example file * Included more information in Readme * Edited example file accodring to linter errors in Pull Request * Edited index.d.ts according to merge conflicts in Pull Request. Had to change a few lines * Edited example file according to linter errors in merge request * Edited example file according to linter errors in merge request. I am starting not to like Travis... * Edited example file according to linter errors in merge request. I am starting not to like Travis...
Does any other open PR do the same thing?
No, there is no other Pull Request doing the same thing.
What issue is this PR fixing?
No issue, it is a new feature.
Requested e.g. here: #1946, #1876
How did you test this PR?
I implemented an application locally with it. It can be recreated with this repo: https://github.com/Stophface/maps. If needed I can create a branch from the repo I doing the pull request with to make an example application.
Which platform (eg. Android/iOS) & Maps API (eg. Google/Apple) does this change affect, if any?
-> Its changes affects both platforms.
Did you test this on a real device, or in a simulator?
-> On iOS and Android simulator.
Are there any platforms you were not able to test?
-> No.
Generally
This feature adds
MBTiles
support forreact-native-maps
. The componentLocalTile
is great. But when there are a lot of maptiles, the downloading, unzipping and managing on the dvivce becomes ressource intensive and slow.MBTiles
is a widely known format to store Map Tiles in aSQLite
database. TheMBTiles
specification was created by Mapbox.Set up a project as usual and include these lines into your application:
Make sure to include the
.mbtiles
ending at the path!An
MBTiles
database can easily be created with various tools e.g.Also make sure that the database uses the
z/x/y
specification of Google, and not theTMS
or another Tile-Specification (information)! TheMBTiles
implementation is based on #1876. It usesFMDB
on iOS to access the database.FMDB
is statically linked toAirMaps.xcodeproj
inlib/ios/
. On Android it usesJDBC
to connect to the database. No linking needed here.JDBC
comes natively with Android. For a complete history please see this repository: https://github.com/Stophface/react-native-maps-0.20.1.