{"id":4505,"url":"https://github.com/surialabs/react-native-geo-fencing","last_synced_at":"2025-08-04T01:32:34.799Z","repository":{"id":41811301,"uuid":"59180481","full_name":"surialabs/react-native-geo-fencing","owner":"surialabs","description":"Native modules to determine if a location is within defined geographical boundaries using Google Geometry library","archived":false,"fork":false,"pushed_at":"2023-04-09T16:31:48.000Z","size":1078,"stargazers_count":138,"open_issues_count":22,"forks_count":33,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-04-26T03:32:52.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/surialabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-05-19T06:37:40.000Z","updated_at":"2024-04-16T20:34:15.000Z","dependencies_parsed_at":"2024-01-08T01:03:23.110Z","dependency_job_id":"16366cce-b8d1-4d34-9f52-79a44dc0a2fa","html_url":"https://github.com/surialabs/react-native-geo-fencing","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"99f80981059e72ef92b630115ea4e44cdc88fa1e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surialabs%2Freact-native-geo-fencing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surialabs%2Freact-native-geo-fencing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surialabs%2Freact-native-geo-fencing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surialabs%2Freact-native-geo-fencing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/surialabs","download_url":"https://codeload.github.com/surialabs/react-native-geo-fencing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228582487,"owners_count":17940587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:14.622Z","updated_at":"2024-12-07T08:30:41.937Z","avatar_url":"https://github.com/surialabs.png","language":"Java","funding_links":[],"categories":["Components","\u003ca name=\"Network:-Native-Modules\"\u003eNetwork: Native Modules\u003c/a\u003e"],"sub_categories":["Geolocation","UI"],"readme":"# react-native-geo-fencing\n\nNative modules to determine if a location is within defined geographical boundaries using Google Geometry library [for ios](https://developers.google.com/maps/documentation/ios-sdk/reference/group___geometry_utils.html#ga8aad2b31a4a4197c919b8da82c84d180) and [android](http://googlemaps.github.io/android-maps-utils/javadoc/com/google/maps/android/PolyUtil.html#containsLocation-LatLng-java.util.List-boolean-).\n\n### Usage\n```js\nimport GeoFencing from 'react-native-geo-fencing';\n```\n```js\n// with navigator geolocation\ncomponentDidMount() {\n  const polygon = [\n    { lat: 3.1336599385978805, lng: 101.31866455078125 },\n    { lat: 3.3091633559540123, lng: 101.66198730468757 },\n    { lat: 3.091150714460597,  lng: 101.92977905273438 },\n    { lat: 2.7222113428196213, lng: 101.74850463867188 },\n    { lat: 2.7153526167685347, lng: 101.47933959960938 },\n    { lat: 3.1336599385978805, lng: 101.31866455078125 } // last point has to be same as first point\n  ];\n\n  navigator.geolocation.getCurrentPosition(\n    (position) =\u003e {\n      let point = {\n        lat: position.coords.latitude,\n        lng: position.coords.longitude\n      };\n\n      GeoFencing.containsLocation(point, polygon)\n        .then(() =\u003e console.log('point is within polygon'))\n        .catch(() =\u003e console.log('point is NOT within polygon'))\n    },\n    (error) =\u003e alert(error.message),\n    { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }\n  );\n}\n```\n\n```js\n// with only point and polygon\ncomponentDidMount() {\n  const polygon = [\n    { lat: 3.1336599385978805, lng: 101.31866455078125 },\n    { lat: 3.3091633559540123, lng: 101.66198730468757 },\n    { lat: 3.091150714460597,  lng: 101.92977905273438 },\n    { lat: 3.1336599385978805, lng: 101.31866455078125 } // last point has to be same as first point\n  ];\n\n  let point = {\n    lat: 2.951269758090068,\n    lng: 101.964111328125\n  };\n\n  GeoFencing.containsLocation(point, polygon)\n    .then(() =\u003e console.log('point is within polygon'))\n    .catch(() =\u003e console.log('point is NOT within polygon'))\n}\n```\n\n### Installation\n    $ npm install --save react-native-geo-fencing\n#### ios\nWithin ```ios/``` directory of your react-native app:\n\n1. Create a  ```Podfile``` manually or simply\n\n    $ pod init\n\n  ```ruby\n  # Podfile for cocoapods 1.0\n  platform :ios, '7.0'\n\n  target 'yourAppTarget' do\n    pod 'React', path: '../node_modules/react-native'\n    pod 'react-native-geo-fencing', path: '../node_modules/react-native-geo-fencing'\n  end\n  ```\n\n  ```ruby\n  # for older version of CocoaPods\n  platform :ios, '7.0'\n\n  pod 'React', path: '../node_modules/react-native'\n  pod 'react-native-geo-fencing', path: '../node_modules/react-native-geo-fencing'\n  ```\n\n2. Then\n\n        $ pod install\n\n3.  Add ```$(inherited)``` for ```Other Linker Flags``` to your project's ```build settings```\n  ![linking_library](/screenshots/linker_flags.png)\n\n4. Link the static library\n  ![linking_binaries](/screenshots/link_binaries.png)\n\n\n#### android\n1. Add the following to ```android/settings.gradle```\n  ```java\n  include ':react-native-geo-fencing'\n  project(':react-native-geo-fencing').projectDir = new File(settingsDir, '../node_modules/react-native-geo-fencing/android')\n  ```\n\n2. Add the following to ```android/app/build.gradle```\n  ```java\n  dependencies {\n    // ...\n    compile project(':react-native-geo-fencing')\n  }\n  ```\n\n3. Edit ```android/src/.../MainActivity.java```\n  ```java\n  // ...\n  import com.surialabs.rn.geofencing.GeoFencingPackage;// \u003c--\n\n  public class MainActivity extends ReactActivity {\n      @Override\n      protected List\u003cReactPackage\u003e getPackages() {\n          return Arrays.\u003cReactPackage\u003easList(\n              new MainReactPackage(),\n              new GeoFencingPackage() // \u003c--\n          );\n      }\n  }\n  ```\n4. Enable access to location when using the app from your ```AndroidManifest.xml```\n\n    ```\u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /\u003e```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurialabs%2Freact-native-geo-fencing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurialabs%2Freact-native-geo-fencing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurialabs%2Freact-native-geo-fencing/lists"}