pavel-corsaghin / react-native-leaflet

A LeafletView component using WebView and Leaflet map for React Native applications
MIT License
99 stars 42 forks source link

Error code -1 Description: net::ERR_FILE_NOT_FOUND #15

Closed BasselTurky closed 2 years ago

BasselTurky commented 2 years ago

I got this error and I can't understand it I am using Expo

Encountered an error loading page, Object { "canGoBack": false, "canGoForward": false, "code": -1, "description": "net::ERR_FILE_NOT_FOUND", "loading": false, "target": 35, "title": "", "url": "file:///android_asset/leaflet.html", } at node_modules\react-native\Libraries\LogBox\LogBox.js:118:10 in registerWarning at node_modules\react-native\Libraries\LogBox\LogBox.js:64:8 in warnImpl at node_modules\react-native\Libraries\LogBox\LogBox.js:37:4 in console.warn at node_modules\expo\build\environment\react-native-logs.fx.js:18:4 in warn at node_modules\react-native-webview\lib\WebView.android.js:165:16 in _this.onLoadingError at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:93:4 in invokeGuardedCallbackProd at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:318:2 in invokeGuardedCallback at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:342:2 in invokeGuardedCallbackAndCatchFirstError at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:439:41 in executeDispatch at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:463:19 in executeDispatchesInOrder at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2563:28 in executeDispatchesAndRelease at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:1214:4 in forEachAccumulated at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2588:20 in runEventsInBatch at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2735:18 in runExtractedPluginEventsInBatch at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2681:35 in batchedUpdates$argument_0 at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18204:13 in batchedUpdates$1 at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2534:29 in batchedUpdates at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2680:16 in _receiveRootNodeIDEvent at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2746:25 in receiveEvent at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __callFunction at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:6 in guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in
guard at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue

This is my code:

import { StyleSheet, Text, View, Button } from "react-native";
import React, { useEffect } from "react";
import { LatLng, LeafletView } from "react-native-leaflet-view";

export default function Home({ navigation }) {

  return (
    <View style={styles.container}>
      <View style={styles.myMap}>
        <LeafletView
          mapLayers={[
            {
              baseLayerName: "MapTiler",
              baseLayerIsChecked: "true",
              baseLayer: "true",
              url: "https://a.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png",
            },
          ]}
        />
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#ffd",
    alignItems: "center",
    justifyContent: "center",
  },
  myMap: {
    flex: 2,
    backgroundColor: "white",
    width: "100%",
    marginTop: 30,
    marginBottom: 30,
  },
  map: {
    width: "100%",
    height: "100%",
  },
});

rn1Capture

rn2Capture

miallo commented 2 years ago

Are you using Expo with the external App by any chance (see #12)? If not: did you run npm run android?

BasselTurky commented 2 years ago

I am using Expo, I tried npm run android but still same error.

BasselTurky commented 2 years ago

Should I eject from Expo?

miallo commented 2 years ago

So far I have only tried it with an ejected Expo app and that is working perfectly. Though I think if I understood the others correctly it also works with Expo, but just not with the QR code and the Expo App

BasselTurky commented 2 years ago

I started new project on React Native CLI and it worked but had to install react-native-webview library first