PHPackages                             tugmaks/yii2-google-maps - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tugmaks/yii2-google-maps

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

tugmaks/yii2-google-maps
========================

Google Maps Yii2 wrapper

712.6k10[1 PRs](https://github.com/tugmaks/yii2-google-maps/pulls)PHP

Since Oct 7Pushed 9y agoCompare

[ Source](https://github.com/tugmaks/yii2-google-maps)[ Packagist](https://packagist.org/packages/tugmaks/yii2-google-maps)[ RSS](/packages/tugmaks-yii2-google-maps/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Google Maps Yii2 wrapper
========================

[](#google-maps-yii2-wrapper)

Google Maps Yii2 wrapper

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist tugmaks/yii2-google-maps "*"

```

or add

```
"tugmaks/yii2-google-maps": "*"

```

to the require section of your `composer.json` file.

MUST READ
---------

[](#must-read)

[Google Maps JavaScript API v3](https://developers.google.com/maps/documentation/javascript/reference)

BASIC USAGE
-----------

[](#basic-usage)

Once the extension is installed, simply use it in your code by :

```
use tugmaks\GoogleMaps\Map;

echo Map::widget([
    'zoom' => 16,
    'center' => 'Red Square',
    'width' => 700,
    'height' => 400,
    'mapType' => Map::MAP_TYPE_SATELLITE,
]);
```

There are two ways to set API KEY:

Add to application parameters.

```
config/params.php

return [
.....
'GOOGLE_API_KEY' => 'VIza7yBgBzYEbKx09V566DhM8Ylc3NjWsJ0ps-2' // use your own api key
.....
]
```

Or pass it direct to widget.

```
use tugmaks\GoogleMaps\Map;

echo Map::widget([
    'apiKey'=> 'VIza7yBgBzYEbKx09V566DhM8Ylc3NjWsJ0ps-2',
    'zoom' => 3,
    'center' => [20, 40.555],
    'width' => 700,
    'height' => 400,
    'mapType' => Map::MAP_TYPE_HYBRID,
]);
```

Parameters

NameDescriptionzoominteger, not required, default 16centerarray or string, required. If array lat and lng will be used, if string search query will be used. For example: `php 'center'=>[23.091,100.412] ` or `php 'center'=>'London, UK' `widthinteger, not required, default 600. Size in $widthUnits default 'px' of div wrapper widthheightinteger, not required, default 600. Size in $heightUnits default 'px' of div wrapper heightwidthUnitsstring, not required, default UNITS\_PX. Available types: UNITS\_PX, UNITS\_PERCENT, UNITS\_EM, UNITS\_REM, UNITS\_VH,UNITS\_VWheightUnitsstring, not required, default UNITS\_PX. Available types: UNITS\_PX, UNITS\_PERCENT, UNITS\_EM, UNITS\_REM, UNITS\_VH,UNITS\_VWmapTypestring, not required, default ROADMAP. Available types: MAP\_TYPE\_ROADMAP, MAP\_TYPE\_HYBRID, MAP\_TYPE\_SATELLITE, MAP\_TYPE\_TERRAINmarkersarray, not required. Markers that will be added to mapMARKERS
-------

[](#markers)

One or more marker can be added to map. Just pass marker array to widget config

```
use tugmaks\GoogleMaps\Map;

echo Map::widget([
    'zoom' => 5,
    'center' => [45, 45],
    'width' => 1100,
    'height' => 600,
    'mapType' => Map::MAP_TYPE_HYBRID,
    'markers' => [
        ['position' => 'Erevan'],
        ['position' => 'Moscow'],
        ['position' => 'Ankara'],
        ['position' => 'Kazan'],
        ['position' => 'Sofia'],
    ]
]);
```

MARKER OPTIONS
--------------

[](#marker-options)

The following options are allowed:

NameDescriptionpositionstring or array, required. If array lat and lng will be used, if string search query will be used.titlestring, not required. Rollover textMARKERS FIT BOUNDS
------------------

[](#markers-fit-bounds)

Sometimes you need to show all markers on map, but do not know initial map center and zoom. In this case use widget like this

```
use tugmaks\GoogleMaps\Map;

echo Map::widget([
    'width' => 1100,
    'height' => 600,
    'mapType' => Map::MAP_TYPE_HYBRID,
    'markers' => [
        ['position' => 'Belgrad'],
        ['position' => 'Zagreb'],
        ['position' => 'Skopje'],
        ['position' => 'Podgorica'],
        ['position' => 'Sarajevo'],
    ],
    'markerFitBounds'=>true
]);
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c3c489ffecb0524e5825675ae8a5d14cec43b2264b750c8a04e8674f9b3ce422?d=identicon)[tugmaks](/maintainers/tugmaks)

---

Top Contributors

[![tugmaks](https://avatars.githubusercontent.com/u/3036462?v=4)](https://github.com/tugmaks "tugmaks (142 commits)")[![vbuchyn](https://avatars.githubusercontent.com/u/9008982?v=4)](https://github.com/vbuchyn "vbuchyn (3 commits)")

### Embed Badge

![Health badge](/badges/tugmaks-yii2-google-maps/health.svg)

```
[![Health](https://phpackages.com/badges/tugmaks-yii2-google-maps/health.svg)](https://phpackages.com/packages/tugmaks-yii2-google-maps)
```

###  Alternatives

[joanhey/adapterman

Use any framework and application with Workerman.

85255.9k1](/packages/joanhey-adapterman)[kunstmaan/seo-bundle

Annotating content with metadata for social sharing and seo purposes cannot be overlooked nowadays. The KunstmaanSeoBundle contains default editing functionality for OpenGraph data, meta descriptions, keywords and titles and Metriweb tags. Because the metatagging and tracking options are always changing, a free field to add custom header information is provided as well.

24130.0k2](/packages/kunstmaan-seo-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
