Skip to content

How to use local .mbtiles file? #591

Answered by KiwiKilian
aLemonFox asked this question in Q&A
Discussion options

You must be logged in to vote

Here is an example a put together the other day with expo-asset, make sure to install it first.

You also need to add this to your Metro Config:

config.resolver.assetExts.push("mbtiles");
import { MapView } from "@maplibre/maplibre-react-native";
import { useAssets } from "expo-asset";

export function App() {
  const [assets] = useAssets([require("../assets/tiles/maplibre.mbtiles")]);

  if (!assets?.[0]?.localUri) {
    return null;
  }

  return (
    <MapView
      style={{ flex: 1 }}
      mapStyle={{
        name: "MapLibre",
        version: 8,
        sources: {
          mbtiles: {
            url: assets[0].localUri.replace("file://", "mbtiles://"),
            type: "vector",

Replies: 7 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

tyrauber
May 20, 2024
Maintainer Sponsor

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@aLemonFox
Comment options

Answer selected by KiwiKilian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #266 on January 04, 2025 22:40.