firesphere/openstreetmaps

前端地图模块。

安装: 195

依赖者: 0

建议者: 0

安全: 0

类型:silverstripe-vendormodule

1.0.5 2024-02-14 01:24 UTC

This package is auto-updated.

Last update: 2024-09-14 02:36:02 UTC


README

GPL v3 或更高版本

使用方法

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##