New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pg-geolocation

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-geolocation

Get current location in android & ios mobile app

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Cordova Plugin Geolocation

Get current location in android & ios mobile app

Example

Installing the Cordova CLI

npm install -g cordova

Create the App

cordova create hello com.example.hello HelloWorld
cd hello

Add Platforms

cordova platform add ios
cordova platform add android

Add plugin

cordova plugin add pg-geolocation
cordova plugin add cordova-plugin-add-swift-support --save

  • Change hello\www\js\index.js
  • Replace onDeviceReady function
onDeviceReady: function() {

  app.receivedEvent('deviceready');

  geolocation.getgeolocation(
    'Geolocation',
    function(msg) {
      document.getElementById('lat').innerHTML = msg[0].lat;
      document.getElementById('lng').innerHTML = msg[1].lng;
    },
    function(err) {
      document.getElementById('lat').innerHTML = err;
    }
  );

  geolocation.getstatus(
    'Plugin Ready',
    function(msg) {
      document.getElementById('deviceready').querySelector('.received').innerHTML = msg;
    },
    function(err) {
      document.getElementById('deviceready').innerHTML = '<p class="event received">' + err + '</p>';
    }
  );

  geolocation.getname(
    'Geolocation plugin',
    function(msg) {
      document.getElementsByTagName('h1')[0].innerHTML = msg;
    },
    function(err) {
      document.getElementsByTagName('h1')[0].innerHTML = err;
    }
  );
},
  • Change hello\www\index.html
<div class="app">
    <h1>Apache Cordova</h1>
    <div id="deviceready" class="blink">
        <p class="event listening">Connecting to Device</p>
        <p class="event received">Device is Ready</p>
    </div>
    <div class="">
      <p>Latitude: <span id="lat"></span></p>
      <p>Longitude: <span id="lng"></span></p>
    </div>
</div>

For IOS

  • Open Xcode & choose team in signing
  • Build Phases > Link Binary With Libraries ==> Add CoreLocation.framework

  • Edit HelloWorld-Info.plist
  • Add privacy location permision

Build app

cordova build ios

Run app in Xcode

For Android

  • Go to platforms/android/src/AndroidManifest.xml
  • Add permission
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Build app

cordova build android

Run app on device

cordova run android

Keywords

FAQs

Package last updated on 15 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc