https://github.com/bakerkretzmar/laravel-mapbox
A Laravel package for managing Mapbox Datasets and Tilesets.
https://github.com/bakerkretzmar/laravel-mapbox
laravel laravel-5-package laravel-package mapbox mapbox-api
Last synced: 27 days ago
JSON representation
A Laravel package for managing Mapbox Datasets and Tilesets.
- Host: GitHub
- URL: https://github.com/bakerkretzmar/laravel-mapbox
- Owner: bakerkretzmar
- License: mit
- Fork: true (BlueVertex/mapbox-api-laravel)
- Created: 2019-06-20T13:31:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-29T14:46:35.000Z (about 6 years ago)
- Last Synced: 2025-11-08T10:25:47.855Z (3 months ago)
- Topics: laravel, laravel-5-package, laravel-package, mapbox, mapbox-api
- Language: PHP
- Homepage:
- Size: 104 KB
- Stars: 7
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Laravel Mapbox
==============
[](https://travis-ci.org/bakerkretzmar/laravel-mapbox)
[](https://github.styleci.io/repos/192925375)
[](https://scrutinizer-ci.com/g/bakerkretzmar/laravel-mapbox/?branch=master)
[](https://scrutinizer-ci.com/g/bakerkretzmar/laravel-mapbox/?branch=master)
[](https://packagist.org/packages/bakerkretzmar/laravel-mapbox)
[](https://packagist.org/packages/bakerkretzmar/laravel-mapbox)
A lightweight wrapper to make working with [Mapbox](https://docs.mapbox.com/api/maps) Maps service APIs in [Laravel](https://laravel.com) apps a breeze. Based on Matt Fox’s [`mapbox-api-laravel`](https://github.com/BlueVertex/mapbox-api-laravel).
This package supports managing the following services via the Mapbox API:
[Datasets](#datasets) • [Features](#features) • [Tilesets](#tilesets) • [Uploads](#uploads)
Installation
------------
```bash
composer require bakerkretzmar/laravel-mapbox
```
Configuration
-------------
Add the following to your `.env` file:
```bash
MAPBOX_USERNAME={your Mapbox username}
MAPBOX_TOKEN={your Mapbox access token}
```
Optionally, you can publish the package’s config file:
```bash
php artisan vendor:publish --provider="bakerkretzmar\LaravelMapbox\LaravelMapboxServiceProvider"
```
Usage
-----
### Datasets
[Mapbox documentation.](https://docs.mapbox.com/api/maps/#datasets)
**List Datasets:**
```php
$datasets = Mapbox::datasets()->list();
```
**Retrieve a Dataset:**
```php
$dataset = Mapbox::datasets($dataset_id)->get();
```
**Create a Dataset:**
```php
$dataset = Mapbox::datasets()->create();
// or
$dataset = Mapbox::datasets()->create([
'name' => 'My Dataset',
'description' => 'A new Mapbox Dataset',
]);
```
**Update a Dataset:**
```php
$dataset = Mapbox::datasets($dataset_id)->update([
'name' => 'My Updated Dataset',
'description' => 'An updated Mapbox Dataset',
]);
```
**Delete a Dataset:**
```php
Mapbox::datasets($dataset_id)->delete();
```
### Features
[Mapbox documentation.](https://docs.mapbox.com/api/maps/#list-features)
**List Features:**
```php
$features = Mapbox::datasets($dataset_id)->features()->list();
// or
$features = Mapbox::features($dataset_id)->list();
```
**Retrieve a Feature:**
```php
$feature = Mapbox::datasets($dataset_id)->features($feature_id)->get();
// or
$feature = Mapbox::features($dataset_id, $feature_id)->get();
```
**Create or update a Feature:**
```php
$feature = Mapbox::datasets($dataset_id)->features()->add($feature);
// or
$feature = Mapbox::features($dataset_id)->add($feature);
```
**Delete a Feature:**
```php
Mapbox::datasets($dataset_id)->features($feature_id)->delete();
// or
Mapbox::features($dataset_id, $feature_id)->delete();
```
### Tilesets
[Mapbox documentation.](https://docs.mapbox.com/api/maps/#tilesets)
**List Tilesets:**
```php
$tilesets = Mapbox::tilesets()->list();
```
**Delete a Tileset:**
```php
Mapbox::tilesets($tileset)->delete();
```
### Uploads
[Mapbox documentation.](https://docs.mapbox.com/api/maps/#uploads)
**Get temporary S3 credentials:**
```php
$credentials = Mapbox::uploads()->credentials();
```
**Create an Upload:**
```php
$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:**
```php
$upload = Mapbox::uploads($upload_id)->get();
```
**List Upload statuses:**
```php
$uploads = Mapbox::uploads()->list();
```
**Delete an Upload:**
```php
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).
```bash
composer test
```
Changelog
---------
See the [CHANGELOG](CHANGELOG.md) for information about what has changed recently.
Security
--------
If you discover any security related issues, please email instead of using the issue tracker.
License
-------
This package is licensed under the MIT License (MIT). Please see the [LICENSE](LICENSE.md) for details.