定制 kematjaya/leaflet-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kematjaya/leaflet-bundle

最新稳定版本:1.0.4

Composer 安装命令:

composer require kematjaya/leaflet-bundle

包简介

provide map for get latitude and longitude base on leaflet.js

README 文档

README

symfony bundle base on leaflet js for selecting location using map

  1. Installation
composer kematjaya/leaflet-bundle
  1. add to config/bundles.php
// add to config/bundles.php
...
Kematjaya\LeafletBundle\LeafletBundle::class => ['all' => true]
...
  1. add to form
// src/Form/AddressType.php
...
use Kematjaya\LeafletBundle\Type\LeafletMapType
...
$builder
      ->add('location', LeafletMapType::class, [
          'label' => 'location',
          "map_height" => "350px", // default 250px
          "map_width" => "100%", // default 100%
      ]);
...
  1. create configuration file config/packages/leaflet.yaml
leaflet:
    map_box: 
        api_token: '%env(resolve:LEAFLET_MAPBOX_TOKEN)%'
    map: 
        lock_map: true # lock map at center point, default true
        lock_coordinates:
            southwest: "-7.777488, 114.776975" # point lock
            northeast: "-7.403438, 110.834149" # point lock
        min_zoom: 8          # minimal zoom available, default 8
        max_zoom: 20         # maximal zoom available, default 20
        zoom_value: 11       # default zoom when map loaded
        on_click_zoom: 14    # zoom when map clicked, default 14
        center_point: '%env(resolve:LEAFLET_MAP_CENTER_POINT)%'
        zoom_point: '%env(resolve:LEAFLET_MAP_CENTER_POINT)%'

and add value to .env

LEAFLET_MAPBOX_TOKEN=your.mapbox.token
LEAFLET_MAP_CENTER_POINT=longlat point ## example: '-7.293421341699741, 112.73709354459358'
  1. use distance calculator
...
use Kematjaya\LeafletBundle\Calculator\Point;
use Kematjaya\LeafletBundle\Calculator\DistanceCalculatorInterface;
...
public function test(DistanceCalculatorInterface $distanceCalculator) 
{
    $from = new Point(-7.345728218434821, 112.76383132697055);
    $to = new Point(-7.2491223553386375, 112.79650342712807);

    $distance = $distanceCalculator->getDistance($from, $to); // in KM
}

统计信息

  • 总下载量: 768
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-16