pincast-sdk

Geolocation Module

The Geolocation Module in the Pincast SDK provides an easy way to access the user’s geolocation. This module returns an object similar to VueUse’s useGeolocation function, including latitude, longitude, and other geolocation information. Additionally, it provides methods to pause and resume geolocation tracking.

Installation

To install the Pincast SDK, follow the Getting Started instructions in the main documentation.

Usage Example

Here’s how to use the Geolocation Module:

import { useGeolocation } from 'pincast-sdk';

const { coords, locatedAt, error, resume, pause } = useGeolocation();

console.log(coords); // Access latitude, longitude, etc.

Output Example

The coords object may look like this:

{
  "accuracy": 0,
  "latitude": null,
  "longitude": null,
  "altitude": null,
  "altitudeAccuracy": null,
  "heading": null,
  "speed": null
}

locatedAt will contain the timestamp when geolocation was last updated, and error will contain any error message if geolocation fails.

API Reference

Example

import { useGeolocation } from 'pincast-sdk';

const { coords, locatedAt, error, resume, pause } = useGeolocation();

// Start tracking geolocation
resume();

// Pause tracking
pause();

// Check for errors
if (error) {
  console.error("Geolocation error:", error);
}

This module provides a straightforward way to access and manage geolocation data within your app, making it easy to build location-based experiences.