pinfirestudios / craft-google-static-maps
提供了一个用于生成Google Maps静态API签名URL的函数
v1.0.1
2018-08-20 02:50 UTC
Requires
- craftcms/cms: ^3.0.0-RC1
This package is auto-updated.
Last update: 2024-09-12 23:16:45 UTC
README
提供了一个用于生成Google Maps静态API签名URL的函数
需求
此插件需要Craft CMS 3.0.0-beta.23或更高版本。
安装
要安装此插件,请按照以下说明操作。
-
打开您的终端并转到您的Craft项目目录
cd /path/to/project
-
然后告诉Composer加载插件
composer require pinfirestudios/google-static-maps
-
在控制面板中,转到设置 → 插件,并点击Google Static Maps的“安装”按钮。
Google静态地图概述
提供了一个TWIG变量,googleStaticMaps,它有一个buildUrl()方法,可以接收URL参数传递给Google Maps API。然后将API密钥添加到查询中,使用URL签名密钥进行签名,并返回URL。还包括一个img()方法,可以正确地为您添加高度/宽度属性。
有关传递到函数中可能的变量的信息,请参阅https://developers.google.com/maps/documentation/maps-static/dev-guide。
配置Google静态地图
将您的API密钥和签名密钥放入配置文件(使用.env)或GUI中。
使用Google静态地图
在twig中
<img src="{{ craft.googleStaticMaps.buildUrl({
center: "0,0",
zoom: "10",
size: "400x400",
}) }}" >
或
{{ craft.googleStaticMaps.img(400, 400, {
center: "0,0",
zoom: 10
}) | raw }}