https://github.com/firesphere/silverstripe-openstreetmaps
Silverstripe Open Street Maps field and frontend map
https://github.com/firesphere/silverstripe-openstreetmaps
Last synced: over 1 year ago
JSON representation
Silverstripe Open Street Maps field and frontend map
- Host: GitHub
- URL: https://github.com/firesphere/silverstripe-openstreetmaps
- Owner: Firesphere
- License: gpl-3.0
- Created: 2023-09-15T07:45:20.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-22T08:12:56.000Z (over 2 years ago)
- Last Synced: 2025-02-01T14:30:17.035Z (over 1 year ago)
- Language: PHP
- Size: 3.24 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Moved to codeberg
https://codeberg.org/Firesphere/silverstripe-openstreetmaps
# Openstreetmaps for Silverstripe
[GPL v3 or later](LICENSE.md)
Usage:
```dotenv
MAPBOX_TOKEN=MyMapboxTokenSecret
```
Static image:
```php
/** @var Location $location */
$location = Location::get()->last();
$service = new OpenStreetmapService();
$image = $service->getStaticMapImage($location, 500, 500, 15);
echo $image->forTemplate();
exit;
```
The following will add a map to a div on your page with id `map`.
If the div doesn't exist, things will break ;)
```php
Requirements::javascript('firesphere/openstreetmaps:dist/js/main.js');
Requirements::css('firesphere/openstreetmaps:dist/css/main.css');
$token = Environment::getEnv('MAPBOX_TOKEN');
Requirements::insertHeadTags(
<<var mapboxtoken = "$token";
JS
);
$service = new OpenStreetmapService();
$locations = Location::get();
if ($locations->exists()) {
$service->addLocations($locations->sort('Primary DESC'));
}
```
# Did you read this entire readme? You rock!
Pictured below is a cow, just for you.
```
/( ,,,,, )\
_\,;;;;;;;,/_
.-"; ;;;;;;;;; ;"-.
'.__/`_ / \ _`\__.'
| (')| |(') |
| .--' '--. |
|/ o o \|
| |
/ \ _..=.._ / \
/:. '._____.' \
;::' / \ .;
| _|_ _|_ ::|
.-| '==o==' '|-.
/ | . / \ | \
| | ::| | | .|
| ( ') (. )::|
|: | |; U U ;|:: | `|
|' | | \ U U / |' | |
##V| |_/`"""`\_| |V##
##V## ##V##
```