PHPackages                             globaloxs/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. globaloxs/yii2-google-maps

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

globaloxs/yii2-google-maps
==========================

Google Maps Yii2 with clusterer wrapper

1411PHP

Since Mar 12Pushed 8y ago3 watchersCompare

[ Source](https://github.com/david-oxs/yii2-google-maps)[ Packagist](https://packagist.org/packages/globaloxs/yii2-google-maps)[ RSS](/packages/globaloxs-yii2-google-maps/feed)WikiDiscussions master Synced 2mo 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 globaloxs/yii2-google-maps "*"

```

or add

```
"globaloxs/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 globaloxs\GoogleMaps\Map;

    echo Map::widget([
        'zoom' => $zoom,
        'center' => $center,
        'width' => 850,
        'height' => 600,
        'mapType' => Map::MAP_TYPE_ROADMAP,
        'markers' => $markers,
        'onClickMarker'=> new \yii\web\JsExpression('function(id, marker,map, infowindow){

        }'),
        'onZoomChanged' => new \yii\web\JsExpression('function() {

        }'),
        'onDragEnd' => new \yii\web\JsExpression('function() {

        }'),
        'markerClustererOptions'=> [
            'imagePath'=> \yii\helpers\Url::to('@web/imgs/circulo-mc')]
        ]);
```

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

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.8% 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/135ca2f1f096bee52256cf95c81baaa9e8e1686f8512a3571eb1c4527715a49a?d=identicon)[davidoxs](/maintainers/davidoxs)

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

---

Top Contributors

[![tugmaks](https://avatars.githubusercontent.com/u/3036462?v=4)](https://github.com/tugmaks "tugmaks (142 commits)")[![globalmikebracas](https://avatars.githubusercontent.com/u/10944824?v=4)](https://github.com/globalmikebracas "globalmikebracas (6 commits)")[![vbuchyn](https://avatars.githubusercontent.com/u/9008982?v=4)](https://github.com/vbuchyn "vbuchyn (3 commits)")[![david-oxs](https://avatars.githubusercontent.com/u/13023718?v=4)](https://github.com/david-oxs "david-oxs (2 commits)")

### Embed Badge

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

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

###  Alternatives

[crisu83/shortid

15125.2k6](/packages/crisu83-shortid)[mihaeu/html-formatter

HTML Formatter pritifies HTML content by applying proper intendation (no tidy, purification, etc.).

1770.8k4](/packages/mihaeu-html-formatter)

PHPackages © 2026

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