2017 © Pedro Peláez
 

yii2-extension yii2-coordinates-input

Map coordinates input widget for Yii 2

image

alexantr/yii2-coordinates-input

Map coordinates input widget for Yii 2

  • Monday, February 19, 2018
  • by alexantr
  • Repository
  • 1 Watchers
  • 1 Stars
  • 98 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 14 % Grown

The README.md

Map coordinates input widget for Yii 2

This extension renders an input with Google map or Yandex map and allows to set coordinates quickly by clicking on the map., (*1)

Latest Stable Version Total Downloads License, (*2)

Installation

Install extension through composer:, (*3)

composer require alexantr/yii2-coordinates-input

Configuring

At first set Google Maps API key in application config. Additionally you can set Yandex Maps language and initial coordinates for all maps., (*4)

[
    'components' => [
        'assetManager' => [
            'bundles' => [
                'alexantr\coordinates\CoordinatesAsset' => [
                    'googleMapsApiKey' => 'UBcsRlxWxBjmZBvrW154fXJ4eJeeO4TFMp9pRLi', // <- put api key here
                    'yandexMapsLang' => 'en_US',
                    'initialCoordinates' => [-53.106392, 73.528748], // [latitude, longitude]
                    'initialZoom' => 8, // Default is 10
                ],
            ],
        ],
    ],
]

Usage

The following code in a view file would render an input with Google map:, (*5)

<?= alexantr\coordinates\CoordinatesInput::widget(['name' => 'attributeName']) ?>

If you want to use this input widget in an ActiveForm, it can be done like this:, (*6)

<?= $form->field($model, 'attributeName')->widget(alexantr\coordinates\CoordinatesInput::className(), ['yandexMaps' => true]) ?>

All widget options with default values:, (*7)

<?= alexantr\coordinates\CoordinatesInput::widget([
    'name' => 'attributeName',
    // there is
    'options' => ['class' => 'form-control coordinates-input'],
    'mapOptions' => ['class' => 'coordinates-map-container'],
    'initialCoordinates' => null,
    'initialZoom' => null,
    'yandexMaps' => false, // Set to true to use Yandex maps instead Google maps
]) ?>

Value of initialCoordinates can be in two formats: [53.923172, 27.540036] or ['lat' => 53.923172, 'lng' => 27.540036]., (*8)

The Versions

19/02 2018

dev-master

9999999-dev

Map coordinates input widget for Yii 2

  Sources   Download

MIT

The Requires

 

yii2 google maps widget map yandex google-maps yandex-maps

14/02 2018

1.0.0

1.0.0.0

Map coordinates input widget for Yii 2

  Sources   Download

MIT

The Requires

 

yii2 google maps widget map yandex google-maps yandex-maps

23/01 2018

v0.0.3

0.0.3.0

Map coordinates input widget for Yii 2

  Sources   Download

MIT

The Requires

 

yii2 google maps widget map yandex google-maps yandex-maps

22/01 2018

v0.0.2

0.0.2.0

Map coordinates input widget for Yii 2

  Sources   Download

MIT

The Requires

 

yii2 google maps widget map yandex google-maps yandex-maps

22/01 2018

v0.0.1

0.0.1.0

Map coordinates input widget for Yii 2

  Sources   Download

MIT

The Requires

 

yii2 google maps widget map yandex google-maps yandex-maps