frolki1_dev / google-embed-php
使用 PHP 集成 Google Maps API
v1.0
2017-04-30 15:34 UTC
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^6.1
This package is auto-updated.
Last update: 2024-09-23 07:33:01 UTC
README
使用 PHP 集成 Google Maps API
要求
要使用此库,您至少需要 PHP 7.0。
安装
Google Embed 可以使用 Composer 安装。运行以下命令:
composer require frolki1_dev/google-embed-php
用法
要使用此库,您需要一个 API 密钥。您可以获取免费版本,因为您可以使用免费嵌入 API。
use Frolki1_Dev\GoogleEmbedMap; $maps = new GoogleEmbedMap(<Add here your api key>); // Create a direction map $direction = $maps->createDirectionsMap(); // Create a place map $place = $maps->createPlaceMap(); // Crsate a search map $search = $maps->createSearchMap(); // Create a view map $view = $maps->createViewMap();
选项
在每种地图类型中,您都有以下选项
// Set a location (street, location, place) $mapType->setLocation(<string>); // Set the center of the view (latitude and longitude) $mapType->setCenter(<float>, <float>); // Set the zoom factor (0 - 21, 0 = Whole world, 21 = A single building) $mapType->setZoom(<int>); // Define the UI language $mapType->setLanguage(<string>); // Show the map as a road map $mapType->useRoadMap(); // Show the map as a satellite map $mapType->useSatelliteMap(); // Get the source (url) $mapType->getSource(); // Build a iframe $mapType->getIFrame();
方向选项
方向地图还具有以下选项和方法
// How the method setLocation but only the start point $direction->start(<string>); // Same how method start but only the destination point $direction->destination(<string>); // Add waypoints (Can be multiple called) $direction->addWayPoint(<string>); // Calculate the route with the car $direction->drivingMode(); // Calculate the route with walking $direction->walkingMode(); // Calculate the route with biking $direction->bicyclingMode(); // Calclate the route with flying $direction->flyingMode(); // Avoid tolls $direction->avoidTolls(); // Avoid Ferry $direction->avoidFerries(); // Avoid Highway $dircetion->avoidHighways(); // Use the metric unit $direction->useMetricUnit(); // Use the imperial unit $direction->useImperialUnit();
许可证
此库是一个开源项目,并受 MIT 许可证 的许可。