Larave-admin 微信海外地圖 (HereMap) 擴充套件包

皮皮強發表於2020-03-06

這個擴充套件包是基於 laravel-admin-extensions/latlong 擴充套件的,解決騰訊地圖在海外無法顯示對應地點。微信海外版使用的諾基亞的here地圖,可以保證顯示效果和國外一致,方便企業發展海外業務。

轉載於我自己的部落格,原文地址 Larave-admin 微信海外地圖(HereMap)擴充套件包

使用效果

Larave-admin 微信海外地圖(HereMap)擴充套件包

原始碼地址

使用方法

composer require pippiqiang/latlong

這個擴充套件用來幫助你在form表單中選擇經緯度,用來替代Laravel-admin中內建的Form\Field\Map元件, 元件支援的地圖包括Google map百度地圖高德地圖騰訊地圖Yadex map.

This extension is used to help you select the latitude and longitude in the form, which is used to replace the Laravel-admin built in Form\Field\Map component. The supported maps include Google map, Baidu map, AMap, Tencent Map, Yadex map.

Installation

composer require laravel-admin-ext/latlong -vvv

Configuration

Open config/admin.php and add the following configuration to the extensions section:


    'extensions' => [

        'latlong' => [

            // Whether to enable this extension, defaults to true
            'enable' => true,

            // Specify the default provider
            'default' => 'google',

            // According to the selected provider above, fill in the corresponding api_key
            'providers' => [

                'google' => [
                    'api_key' => '',
                ],

                'yadex' => [
                    'api_key' => '',
                ],

                'baidu' => [
                    'api_key' => 'xck5**************************dx',
                ],

                'tencent' => [
                    'api_key' => 'VV***-*****-*****-*****-*****-**BBT',
                ],

                'amap' => [
                    'api_key' => '3693**************************fb',
                ],

                'here' => [
                    'app_key' => 'ge*************************************WeD0'
                ],
            ]
        ]
    ]

Usage

Suppose you have two fields latitude and longitude in your table that represent latitude and longitude, then use the following in the form:

$form->latlong('latitude', 'longitude', 'Position');

// Set the map height
$form->latlong('latitude', 'longitude', 'Position')->height(500);

// Set the map zoom
$form->latlong('latitude', 'longitude', 'Position')->zoom(16);

// Set default position
$form->latlong('latitude', 'longitude', 'Position')->default(['lat' => 90, 'lng' => 90]);

Use in show page

$show->field('Position')->latlong('lat_column', 'long_column', $height = 400, $zoom = 16);

License

Licensed under The MIT License (MIT).

本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章