LaravelPackages.net
Acme Inc.
Toggle sidebar
bakerkretzmar/laravel-mapbox

A Laravel package for managing Mapbox Datasets and Tilesets.

2.011
7
1.1.1
About bakerkretzmar/laravel-mapbox

bakerkretzmar/laravel-mapbox is a Laravel package for a laravel package for managing mapbox datasets and tilesets.. It currently has 7 GitHub stars and 2.011 downloads on Packagist (latest version 1.1.1). Install it with composer require bakerkretzmar/laravel-mapbox. Discover more Laravel packages by bakerkretzmar or browse all Laravel packages to compare alternatives.

Last updated

Laravel Mapbox

Build status StyleCI Scrutinizer code quality Code coverage Latest stable version Total downloads

A lightweight wrapper to make working with Mapbox Maps service APIs in Laravel apps a breeze. Based on Matt Fox’s mapbox-api-laravel.

This package supports managing the following services via the Mapbox API:

DatasetsFeaturesTilesetsUploads

Installation

composer require bakerkretzmar/laravel-mapbox

Configuration

Add the following to your .env file:

MAPBOX_USERNAME={your Mapbox username}
MAPBOX_TOKEN={your Mapbox access token}

Optionally, you can publish the package’s config file:

php artisan vendor:publish --provider="bakerkretzmar\LaravelMapbox\LaravelMapboxServiceProvider"

Usage

Datasets

Mapbox documentation.

List Datasets:

$datasets = Mapbox::datasets()->list();

Retrieve a Dataset:

$dataset = Mapbox::datasets($dataset_id)->get();

Create a Dataset:

$dataset = Mapbox::datasets()->create();
// or
$dataset = Mapbox::datasets()->create([
    'name' => 'My Dataset',
    'description' => 'A new Mapbox Dataset',
]);

Update a Dataset:

$dataset = Mapbox::datasets($dataset_id)->update([
    'name' => 'My Updated Dataset',
    'description' => 'An updated Mapbox Dataset',
]);

Delete a Dataset:

Mapbox::datasets($dataset_id)->delete();

Features

Mapbox documentation.

List Features:

$features = Mapbox::datasets($dataset_id)->features()->list();
// or
$features = Mapbox::features($dataset_id)->list();

Retrieve a Feature:

$feature = Mapbox::datasets($dataset_id)->features($feature_id)->get();
// or
$feature = Mapbox::features($dataset_id, $feature_id)->get();

Create or update a Feature:

$feature = Mapbox::datasets($dataset_id)->features()->add($feature);
// or
$feature = Mapbox::features($dataset_id)->add($feature);

Delete a Feature:

Mapbox::datasets($dataset_id)->features($feature_id)->delete();
// or
Mapbox::features($dataset_id, $feature_id)->delete();

Tilesets

Mapbox documentation.

List Tilesets:

$tilesets = Mapbox::tilesets()->list();

Delete a Tileset:

Mapbox::tilesets($tileset)->delete();

Uploads

Mapbox documentation.

Get temporary S3 credentials:

$credentials = Mapbox::uploads()->credentials();

Create an Upload:

$upload = Mapbox::uploads()->create([
    'tileset' => 'my_tileset_name',
    'url' => 'http://{bucket}.s3.amazonaws.com/{key}',
    'name' => 'My Tileset',
]);
// or
$upload = Mapbox::uploads()->create([
    'tileset' => 'my_tileset_name',
    'dataset' => 'my_dataset_id',
    'name' => 'My Tileset',
]);

Retrieve an Upload’s status:

$upload = Mapbox::uploads($upload_id)->get();

List Upload statuses:

$uploads = Mapbox::uploads()->list();

Delete an Upload:

Mapbox::uploads($upload_id)->delete();

Testing

Note — Tests hit the real Mapbox API. Before testing the package, set up a local testing environment file with valid Mapbox credentials (cp .env.testing.example .env.testing and fill in the blanks).

composer test

Changelog

See the CHANGELOG for information about what has changed recently.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

This package is licensed under the MIT License (MIT). Please see the LICENSE for details.

Star History Chart