PHP code example of quexer69 / yii2-google-api
1. Go to this page and download the library: Download quexer69/yii2-google-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
quexer69 / yii2-google-api example snippets
'components' => [
'googleApi' => [
'class' => 'quexer\googleapi\GoogleApiLibrary' ,
'staticmap_api_key' => '***************************************' ,
'geocode_api_key' => '***************************************' ,
'webroot' => '@webroot' ,
'map_image_path' => '/images/google_map' ,
'map_type' => 'terrain' ,
'map_size' => '520x350' ,
'map_sensor' => false ,
'map_zoom' => 9 ,
'map_scale' => 1 ,
'map_marker_color' => 'red' ,
'map_iframe_width' => '100%' ,
'map_iframe_height' => '500px' ,
'map_language' => 'de' ,
'quiet' => false
],
...
],
\Yii::$app->googleApi->renderMapIframe($address, $latlng, $iFrameWidth, $iFrameHeight)
\Yii::$app->googleApi->createImage($address, $latlng, $setMarker)
\Yii::$app->googleApi->getGeoCodeObject($address, $latlng)
\Yii::$app->googleApi->getDistance($start, $finish, $unit)
\Yii::$app->googleApi->getBounds($address)
$address = '70180 Stuttgart, Germany' ;
$latlng = '48.7632145,9.174027' ;
$relFilePath = \Yii::$app->googleApi->createImage($address, null , true );
$relFilePath = \Yii::$app->googleApi->getGeoCodeObject(null , $latlng);
$iframeMarkup = \Yii::$app->googleApi->renderMapIframe(null , $latlng);
$latlng_origin = ['48.7632145' ,'9.174027' ];
$latlng_destination = ['48.4525334' ,'9.468254' ];
$unit = 'miles' ;
$floatDistance = \Yii::$app->googleApi->getDistance($latlng_origin, $latlng_destination, $unit);
php composer.phar