npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thyrith/react-native-geo-fencing

v0.0.2

Published

Native modules to determine if a location is within defined geographical boundaries using Google Geometry library

Downloads

2

Readme

react-native-geo-fencing

Native modules to determine if a location is within defined geographical boundaries using Google Geometry library for ios and android.

Usage

import GeoFencing from '@thyrith/react-native-geo-fencing';
// with navigator geolocation
componentDidMount() {
  const polygon = [
    { lat: 3.1336599385978805, lng: 101.31866455078125 },
    { lat: 3.3091633559540123, lng: 101.66198730468757 },
    { lat: 3.091150714460597,  lng: 101.92977905273438 },
    { lat: 2.7222113428196213, lng: 101.74850463867188 },
    { lat: 2.7153526167685347, lng: 101.47933959960938 },
    { lat: 3.1336599385978805, lng: 101.31866455078125 } // last point has to be same as first point
  ];

  navigator.geolocation.getCurrentPosition(
    (position) => {
      let point = {
        lat: position.coords.latitude,
        lng: position.coords.longitude
      };

      GeoFencing.containsLocation(point, polygon)
        .then(() => console.log('point is within polygon'))
        .catch(() => console.log('point is NOT within polygon'))
    },
    (error) => alert(error.message),
    { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
  );
}
// with only point and polygon
componentDidMount() {
  const polygon = [
    { lat: 3.1336599385978805, lng: 101.31866455078125 },
    { lat: 3.3091633559540123, lng: 101.66198730468757 },
    { lat: 3.091150714460597,  lng: 101.92977905273438 },
    { lat: 3.1336599385978805, lng: 101.31866455078125 } // last point has to be same as first point
  ];

  let point = {
    lat: 2.951269758090068,
    lng: 101.964111328125
  };

  GeoFencing.containsLocation(point, polygon)
    .then(() => console.log('point is within polygon'))
    .catch(() => console.log('point is NOT within polygon'))
}

Installation

$ npm install --save @thyrith/react-native-geo-fencing

ios

Within ios/ directory of your react-native app:

  1. Create a Podfile manually or simply

    $ pod init

# Podfile for cocoapods 1.0
platform :ios, '7.0'

target 'yourAppTarget' do
  pod 'React', path: '../node_modules/react-native'
  pod 'react-native-geo-fencing', path: '../node_modules/@thyrith/react-native-geo-fencing'
end
# for older version of CocoaPods
platform :ios, '7.0'

pod 'React', path: '../node_modules/react-native'
pod 'react-native-geo-fencing', path: '../node_modules/@thyrith/react-native-geo-fencing'
  1. Then

     $ pod install
  2. Add $(inherited) for Other Linker Flags to your project's build settings linking_library

  3. Link the static library linking_binaries

android

  1. Add the following to android/settings.gradle
include ':@thyrith_react-native-geo-fencing'
project(':@thyrith_react-native-geo-fencing').projectDir = new File(settingsDir, '../node_modules/@thyrith/react-native-geo-fencing/android')
  1. Add the following to android/app/build.gradle
dependencies {
  // ...
  compile project(':thyrith_react-native-geo-fencing')
}
  1. Edit android/src/.../MainActivity.java
// ...
import com.surialabs.rn.geofencing.GeoFencingPackage;// <--

public class MainActivity extends ReactActivity {
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new GeoFencingPackage() // <--
        );
    }
}
  1. Enable access to location when using the app from your AndroidManifest.xml

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />