內容簡介
這個外掛是由Stupid Studio修改延伸出來的「進階自訂欄位:座標」版本,可於此處找到:
https://wordpress.org/plugins/advanced-custom-fields-coordinates/
本軟體採用GNU通用公共授權條款第3版進行授權。有關詳細內容,請參見附帶於本軟體中的gpl.txt檔案。
此外掛程式相依於Google Maps API,不使用API金鑰,因此在符合免費Google Maps API限制下操作,對於大部分的後端使用需求應該是足夠的。
使用方法
當您使用ACF(進階自訂欄位)建立新的自訂欄位時,將欄位類型設定為多重座標地圖。現在當您編輯帶有自訂欄位的文章時,座標選擇工具應該會顯示出來。
此工具在每次點擊地圖時新增一個點,若要移除該點,請選擇「移除座標」按鈕並點擊點。您也可以使用「在地圖上顯示範圍」按鈕以多邊形的方式在地圖上顯示點,並且使用「顯示座標」按鈕以分號分隔的清單形式來顯示實際座標。搜尋欄位僅提供快速尋找地圖上不同的地方,並不用於新增實際座標點。
為了在前端獲取座標資料,只需請求欄位值,並將座標以緯度、經度的陣列形式加以回傳,同時也可取得所在的縮放大小,如以下範例。
<?php
$values = get_field('*****FIELD_NAME*****');
print_r($values);
/* 您將會獲得像以下範例一樣的陣列
Array
(
[coords] => Array
(
[0] => Array
(
[lat] => 57.156363766336
[lng] => 16.364327427978
)
[1] => Array
(
[lat] => 57.159612809986
[lng] => 16.370315551758
)
)
[zoom] => 13
)
*/
?>
外掛標籤
開發者團隊
② 後台搜尋「Advanced Custom Fields: Multiple Coordinates」→ 直接安裝(推薦)
原文外掛簡介
The plugin is a modified extended version of the Advanced Custom Fields: Coordinates made by Stupid Studio and is found here:
https://wordpress.org/plugins/advanced-custom-fields-coordinates/
This software is licensed under the GNU General Public License version 3. See
gpl.txt included with this software for more detail.
The plugin relies on the Google Maps API. It does not use an API-key and is
therefore operating under the restrictions of the free Google Maps API,
which should be plenty for most backend usage.
Usage
When you create a new custom field with ACF, set the field type to
Multiple Coordinates map. Now the coordinates chooser should show up when you edit
a post with your custom fields.
The tool add a point on each click on the map. To remove the point you select the “Remove Coordinate” button and click a point.
You can also show the points as a Polygon on the map with the “Show area on map” button and show the actual coordinates in a semi-colon
separated list with the “Show coordinates” button. The search field is only there to quickly take you to different places on the map. Not
to add the actual points.
To get the coordinates data in your frontend, simply request the field value
and in return you get the coordinates in a latitude, longitude array and the zoom as in the sample below.
Array
(
[0] => Array
(
[lat] => 57.156363766336
[lng] => 16.364327427978
)
[1] => Array
(
[lat] => 57.159612809986
[lng] => 16.370315551758
)
)
[zoom] => 13
)
*/
?>
