Plugin EcosystemHardware & Sensors
GPS / Geolocation
Precision tracking and geolocation services for EasyCord applications.
GPS Plugin
The EasyCord GPS plugin provides precise device location data, continuous tracking capabilities, and geofencing utilities tailored for enterprise logistics and tracking apps.
Installation
npm install @easycord/plugin-gpsAPI Reference
getCurrentPosition(options?: PositionOptions)
Retrieves the current GPS coordinates of the device.
Parameters
enableHighAccuracy(boolean): Requests highly accurate GPS hardware data.timeout(number): Maximum time in ms to wait for a location.
Example Usage
import { useState } from 'react';
import { GPS } from '@easycord/plugin-gps';
export default function LocationTracker() {
const [location, setLocation] = useState<{ lat: number; lng: number } | null>(null);
const fetchLocation = async () => {
try {
const position = await GPS.getCurrentPosition({ enableHighAccuracy: true });
setLocation({ lat: position.coords.latitude, lng: position.coords.longitude });
} catch (err) {
console.error('Location error:', err);
}
};
return (
<div className="p-4">
<button onClick={fetchLocation} className="bg-green-600 text-white px-4 py-2 rounded">
Get Location
</button>
{location && (
<p className="mt-4 text-gray-700">
Lat: {location.lat.toFixed(4)}, Lng: {location.lng.toFixed(4)}
</p>
)}
</div>
);
}