PHP code example of denniskrol / nativephp-geolocation

1. Go to this page and download the library: Download denniskrol/nativephp-geolocation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

denniskrol / nativephp-geolocation example snippets


use Denniskrol\NativePHPGeolocation\Facades\Geolocation;

// Ask the OS for location permission (no-op if already granted)
$perm = Geolocation::requestPermission();

// Then read the position
$pos = Geolocation::getCurrentPosition(highAccuracy: true);

// $pos = ['success' => true, 'latitude' => ..., 'longitude' => ..., 'accuracy' => ...]

// While the app is open, open Android's permission settings when needed.
$background = Geolocation::requestBackgroundPermission();

// Use this from a background runtime after background permission is granted.
$pos = Geolocation::getBackgroundPosition(highAccuracy: false);
bash
php artisan native:run android
# or
php artisan native:run ios