firesphere / openstreetmaps
前端地图模块。
1.0.5
2024-02-14 01:24 UTC
Requires
README
使用方法
MAPBOX_TOKEN=MyMapboxTokenSecret
静态图像
/** @var Location $location */ $location = Location::get()->last(); $service = new OpenStreetmapService(); $image = $service->getStaticMapImage($location, 500, 500, 15); echo $image->forTemplate(); exit;
以下代码将地图添加到您的页面上的 id 为 map
的 div 中。
如果 div 不存在,会发生错误 ;)
Requirements::javascript('firesphere/openstreetmaps:dist/js/main.js'); Requirements::css('firesphere/openstreetmaps:dist/css/main.css'); $token = Environment::getEnv('MAPBOX_TOKEN'); Requirements::insertHeadTags( <<<JS <script type="text/javascript">var mapboxtoken = "$token";</script> JS ); $service = new OpenStreetmapService(); $locations = Location::get(); if ($locations->exists()) { $service->addLocations($locations->sort('Primary DESC')); }
您已经阅读了整个 README 吗?太棒了!
下面有一头牛,仅为您。
/( ,,,,, )\
_\,;;;;;;;,/_
.-"; ;;;;;;;;; ;"-.
'.__/`_ / \ _`\__.'
| (')| |(') |
| .--' '--. |
|/ o o \|
| |
/ \ _..=.._ / \
/:. '._____.' \
;::' / \ .;
| _|_ _|_ ::|
.-| '==o==' '|-.
/ | . / \ | \
| | ::| | | .|
| ( ') (. )::|
|: | |; U U ;|:: | `|
|' | | \ U U / |' | |
##V| |_/`"""`\_| |V##
##V## ##V##