2017 © Pedro Peláez
 

yii2-extension yii2-google-api

A collection of google map api calls, staticmap, geocode, iframe, for google api v3

image

quexer69/yii2-google-api

A collection of google map api calls, staticmap, geocode, iframe, for google api v3

  • Monday, August 14, 2017
  • by Quexer69
  • Repository
  • 1 Watchers
  • 2 Stars
  • 681 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 7 Versions
  • 7 % Grown

The README.md

# Yii2 google api library

Latest Stable Version Total Downloads License, (*1)

A collection of google map api calls, staticmap, geocode, iframe map, (*2)

...for Google API v3, PHP >= 5.4.0, Yii 2.0.*, (*3)

Installation

The preferred way to install this component is through composer., (*4)

Either run, (*5)

php composer.phar require --prefer-dist quexer69/yii2-google-api "2.0.*"

or add, (*6)

"quexer69/yii2-google-api": "2.0.*"

to the require section of your composer.json file., (*7)

Configuration

in your app and/or console configuration file, add these, (*8)

'components' => [

    // Google Maps Image and Geocode API settings for \Yii::$app->googleApi component
    'googleApi'   => [
            'class'             => 'quexer\googleapi\GoogleApiLibrary',

            // API Keys !!!
            'staticmap_api_key' => '***************************************',
            'geocode_api_key'   => '***************************************',

            // Set basePath
            'webroot'           => '@webroot',

            // Image path and map iframe settings
            '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%', // %, px, em
            'map_iframe_height' => '500px',  // %, px, em
            'map_language'        => 'de',

            // Debug
            'quiet'             => false
    ],
    ...
],

Public Methods

\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)

Usage

Once the component is installed, simply use it in your code by:, (*9)

// Use $address OR $latlng
$address              = '70180 Stuttgart, Germany';
$latlng               = '48.7632145,9.174027';

Create a Google map image, (*10)

$relFilePath          = \Yii::$app->googleApi->createImage($address, null, true);

To simply get the Google geocode object, (*11)

$relFilePath          = \Yii::$app->googleApi->getGeoCodeObject(null, $latlng);

Render a Google map iframe, (*12)

$iframeMarkup         = \Yii::$app->googleApi->renderMapIframe(null, $latlng);

Calculate Distance between two geo points, (*13)

$latlng_origin        = ['48.7632145','9.174027'];
$latlng_destination   = ['48.4525334','9.468254'];
$unit                 = 'miles'; // 'miles' or 'km'

$floatDistance        = \Yii::$app->googleApi->getDistance($latlng_origin, $latlng_destination, $unit);

See also

... a more extensive variant * 2amigos/yii2-google-maps-library, (*14)

Resources

The Versions

14/08 2017

dev-master

9999999-dev

A collection of google map api calls, staticmap, geocode, iframe, for google api v3

  Sources   Download

BSD-3-Clause

The Requires

 

api extension yii2 google google map

22/12 2016

2.0.3

2.0.3.0

A collection of google map api calls, staticmap, geocode, iframe, for google api v3

  Sources   Download

BSD-3-Clause

The Requires

 

api extension yii2 google google map

24/01 2015

2.0.2

2.0.2.0

A collection of google map api calls, staticmap, geocode, iframe, for google api v3

  Sources   Download

BSD-3-Clause

The Requires

 

api extension yii2 google google map

24/01 2015

2.0.1

2.0.1.0

A collection of google map api calls, staticmap, geocode, iframe, for google api v3

  Sources   Download

BSD-3-Clause

The Requires

 

api extension yii2 google google map

24/01 2015

2.0.0

2.0.0.0

A collection of google map api calls, staticmap, geocode, iframe, for google api v3

  Sources   Download

BSD-3-Clause

The Requires

 

api extension yii2 google google map

24/01 2015

1.1.0

1.1.0.0

A collection of google map api calls, staticmap, geocode, iframe, for google api v3

  Sources   Download

BSD-3-Clause

The Requires

 

api extension yii2 google google map

23/01 2015

1.0.0

1.0.0.0

A collection of google map api calls, staticmap, geocode, iframe, for google api v3

  Sources   Download

BSD-3-Clause

The Requires

 

api extension yii2 google google map