@yaseenalmufti/fast-geolocation
v1.0.4
Published
This Plugin will return the latitude, longitude, city, state, and country in a fast manner to be used for simple location services
Readme
FastGeolocation
Fast native geolocation plugin for Capacitor that returns city, state, and country using on-device reverse geocoding.
✨ Features
- ✅ Fast native geolocation
- 🌍 Reverse geocoding (City, State, Country)
- ⚡ Works offline with on-device services (no external APIs)
📦 Installation
npm install @yaseenalmufti/fast-geolocation
npx cap sync🔧 Platform Support
| Platform | Supported | |----------|-----------| | Android | ✅ | | iOS | ✅ | | Web | ❌ |
📚 Usage
import { FastGeolocation } from '@yaseenalmufti/fast-geolocation';
const getLocation = async () => {
try {
const location = await FastGeolocation.getCurrentCity();
console.log(\`You are in \${location.city}, \${location.state}, \${location.country}\`);
} catch (error) {
console.error('Error getting location:', error);
}
};📥 API
getCurrentCity(): Promise<CityLocation>
Returns the current GPS location and reverse-geocoded city, state, and country.
CityLocation structure:
interface CityLocation {
latitude: number;
longitude: number;
city: string;
state: string;
country: string;
}⚙️ Android Setup
In android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />The plugin uses:
FusedLocationProviderClientfor fast location accessGeocoderfor native reverse geocoding
⚙️ iOS Setup
In ios/App/App/Info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to determine your city</string>The plugin uses:
CLLocationManagerfor GPS accessCLGeocoderfor native reverse geocoding
🧑💻 Author
Yaseen Almufti
- GitHub: @yaseenalmufti
- npm: @yaseenalmufti
📝 License
MIT
