{"id":22445203,"url":"https://github.com/grayhat12/gray-geolocation","last_synced_at":"2026-03-12T02:33:13.080Z","repository":{"id":57193979,"uuid":"300696443","full_name":"GrayHat12/gray-geolocation","owner":"GrayHat12","description":"A capacitorjs plugin that turns on device location","archived":false,"fork":false,"pushed_at":"2022-09-30T12:27:36.000Z","size":217,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T20:15:31.943Z","etag":null,"topics":["capacitor-android","capacitor-plugin","geolocation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/capacitor-gray-geolocation","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GrayHat12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-02T17:59:12.000Z","updated_at":"2025-02-11T01:29:40.000Z","dependencies_parsed_at":"2022-09-01T23:40:34.396Z","dependency_job_id":null,"html_url":"https://github.com/GrayHat12/gray-geolocation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrayHat12%2Fgray-geolocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrayHat12%2Fgray-geolocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrayHat12%2Fgray-geolocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrayHat12%2Fgray-geolocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrayHat12","download_url":"https://codeload.github.com/GrayHat12/gray-geolocation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248774966,"owners_count":21159534,"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":["capacitor-android","capacitor-plugin","geolocation"],"created_at":"2024-12-06T03:12:28.542Z","updated_at":"2026-03-12T02:33:13.015Z","avatar_url":"https://github.com/GrayHat12.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# capacitor-gray-geolocation\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/capacitor-gray-geolocation\"\u003e\n        \u003cimg src=\"https://badge.fury.io/js/capacitor-gray-geolocation.svg?kill_cache=1\" alt=\"npm version\" /\u003e\n    \u003c/a\u003e\n        \u003ca href=\"https://snyk.io/test/npm/capacitor-gray-geolocation\"\u003e\n            \u003cimg src=\"https://snyk.io/test/npm/capacitor-gray-geolocation/badge.svg\" alt=\"Known Vulnerabilities\" /\u003e\n        \u003c/a\u003e\n    \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/License-MIT-GREEN.svg\" alt=\"License\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Description\n\nGeolocation plugin that uses the fused location service instead of the native API.\n\nGetting a location under android is quite difficult. The standard API implemented now in capacitor returns the GPS provider which results in never getting a position indoors. This is not the case under iOS. A better way under Android is the [FusedLocationProvider](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient) which already handles that.\n\nThis Plugin also has method calls to turn on location.\n\n--------------------\n\n## Supported platforms\n\n- Android\n- Web\n\n--------------------\n\n## Install\n\n```bash\nnpm install capacitor-gray-geolocation\nnpx cap sync\n```\n\n--------------------\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`turnLocationOn()`](#turnlocationon)\n* [`getCurrentPosition()`](#getcurrentposition)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\n### turnLocationOn()\n\n```typescript\nturnLocationOn() =\u003e Promise\u003c{ res: boolean; }\u003e\n```\n\nThis prompts the user on android to turn location on.\nFirtstly checks for location permissions and if they are not granted, it prompts the user to grant permissions.\nAlways returns `{res: true}` for web.\nNot implemented on iOS.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ res: boolean; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### getCurrentPosition()\n\n```typescript\ngetCurrentPosition() =\u003e Promise\u003c{ latitude: number; longitude: number; }\u003e\n```\n\nReturns current position of the device.\nFirtstly checks for location permissions and if they are not granted, it prompts the user to grant permissions.\nNot implemented on iOS.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ latitude: number; longitude: number; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\u003c/docgen-api\u003e\n\n\n## Example\n\n```js\n// Inside the Ionic code\n\nimport { Device } from \"@capacitor/device\";\nimport { GrayGeolocation } from \"capacitor-gray-geolocation\";\n\n// ...code\n\n//function to get location (handle errors yourself) \ngetLocation = async() =\u003e {\n    let deviceInfo = await Device.getInfo();\n    if(deviceInfo.platform === \"ios\") {\n        //use the capacitor Plugins.Geolocation for geolocation\n        return;\n    }\n    let locationOn = await GrayGeolocation.turnLocationOn();\n    if(locationOn.res) {\n        let coords = await GrayGeolocation.getCurrentPosition();\n        console.log(\"latitude :\",coords.latitude,\"longitude :\",coords.longitude);\n        return coords;\n    }\n    else{\n        //failed to turn on location : User declined\n    }\n}\n```\n\n```java\n// Inside the Android code (MainActivity.java)\n\n// ... imports\nimport com.gray.plugins.capacitor.GrayGeolocationPlugin;\n\npublic class MainActivity extends BridgeActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        // ... register other plugins if any\n        registerPlugin(GrayGeolocationPlugin.class);\n        super.onCreate(savedInstanceState);\n    }\n}\n```\n\n--------------------\n\n## Testing\n\nManually tested against the following platforms:\n\n* Android device 11.0 (API Level 30)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrayhat12%2Fgray-geolocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrayhat12%2Fgray-geolocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrayhat12%2Fgray-geolocation/lists"}