Giter Site home page Giter Site logo

splicer97 / react-native-osmdroid Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 2.0 4.45 MB

React Native wrapper for osmdroid maps

License: MIT License

Java 61.23% JavaScript 0.88% Ruby 0.78% Starlark 0.29% CMake 0.13% C++ 3.51% Swift 0.03% C 0.05% Objective-C 1.15% Objective-C++ 2.14% TypeScript 29.80%

react-native-osmdroid's People

Contributors

splicer97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

react-native-osmdroid's Issues

UrlTile does not show tiles.

this is my App component:

import MapView, { UrlTile } from '@splicer97/react-native-osmdroid';
import React, { useEffect } from 'react';
import { PermissionsAndroid, View } from 'react-native';
import ReactNativeFileStream from 'react-native-fs';

const App = () => {

  useEffect(() => {
    requestPermission();
    checkIsExistTile();
  },
    [])

  const uri = `file://${ReactNativeFileStream.DownloadDirectoryPath}/Tiles/0/0/0.png`;
  console.log(uri) // file:///storage/emulated/0/Download/Tiles/0/0/0.png

  const checkIsExistTile = async () => {
    const isExist = await ReactNativeFileStream.exists(`file://${ReactNativeFileStream.DownloadDirectoryPath}/Tiles/0/0/0.png`)
    console.log(isExist)
  }

  const requestPermission = async () => {
    const WRITE_EXTERNAL_STORAGE = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      {
        title: 'Permission',
        message: 'Message',
        buttonNeutral: 'Ask Me Later',
        buttonNegative: 'Cancel',
        buttonPositive: 'OK',
      },
    );
    console.log(WRITE_EXTERNAL_STORAGE === PermissionsAndroid.RESULTS.GRANTED)


    const READ_EXTERNAL_STORAGE = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
      {
        title: 'Permission',
        message: 'Message',
        buttonNeutral: 'Ask Me Later',
        buttonNegative: 'Cancel',
        buttonPositive: 'OK',
      },
    );
    console.log(READ_EXTERNAL_STORAGE === PermissionsAndroid.RESULTS.GRANTED)


    const ACCESS_FINE_LOCATION = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
      {
        title: 'Permission',
        message: 'Message',
        buttonNeutral: 'Ask Me Later',
        buttonNegative: 'Cancel',
        buttonPositive: 'OK',
      },
    );
    console.log(ACCESS_FINE_LOCATION === PermissionsAndroid.RESULTS.GRANTED)
  }

  return (
    <View style={{ flex: 1 }}>
      <MapView style={{ width: "100%", height: "100%" }}
        initialRegion={{ latitude: 29.5918, longitude: 52.5837, latitudeDelta: 0.0922, longitudeDelta: 0.0421 }}>
        <UrlTile urlTemplate={`file://${ReactNativeFileStream.DownloadDirectoryPath}/Tiles/{z}/{x}/{y}.png`} />
      </MapView>

      {/* to approve that tile is exit  */}
      {/* <Image source={{ uri }} style={{ width: 500, height: 500 }} /> */}
    </View>
  )
}
export default App;


my package.json:

{
  "name": "maposmdroid",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@splicer97/react-native-osmdroid": "^0.14.0",
    "react": "18.2.0",
    "react-native": "0.73.1",
    "react-native-fs": "^2.19.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "^0.73.18",
    "@react-native/eslint-config": "^0.73.1",
    "@react-native/metro-config": "^0.73.2",
    "@react-native/typescript-config": "^0.73.1",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

I copied those tiles in the download folder:
tiles

And:

emulator-tiled-folder

My AndroidManifest.xml


<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"  />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />                                               

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
    </application>
</manifest>

why it does not show tiles?

react-native-osmdroid doesn't support android

Hey,

I have trouble to get an Google Maps Key, and I don't really need gmaps.

I've found your module and thought great... but now I get this Errror:

react-native-osmdroid doesn't support android

I was using Expo SDK 44 and older react native, because I have trouble to compile higher Versions due to dependencies missmatch. Compiled Version with SDK was working but crashes when opening original Map View because no API Key is set. Even with WMTS Maps.. great. (So It's not crashing generally)

What ever, I've upgraded to newest Expo SDK 48 and react-native 0.71.6 (since ur using above 0.70 and i was using below)

I still get the Error when I open the Map Component.

Is the Component not compatible with expo? The Base was I guess

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.