Download the PHP package prinf/yii2-map-input-widget without Composer
On this page you can find all versions of the php package prinf/yii2-map-input-widget. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download prinf/yii2-map-input-widget
More information about prinf/yii2-map-input-widget
Files in prinf/yii2-map-input-widget
Package yii2-map-input-widget
Short Description Fork of kolyunya/yii2-map-input-widget. Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly interface.
License GNU GPL v3.0
Homepage https://github.com/prinf/yii2-map-input-widget
Informations about the package yii2-map-input-widget
Yii2 map input widget
Description
A Yii2 input widget which provides a user-friendly interface for selecting geographical coordinates via Google maps. Allows users to select geographical coordinates by clicking on an interative Google map embedded into you web-page.
The widget is composer-enabled. You can aquire the latest available version from the packagist repository.
Demo
A simple widget demo is available here. You may inspect the hidden input value via some web-developer tool (e.g. Firebug) to see how geographical coordinates are represented inside the widget.
Usage examples
Minimal example
To reproduce the following minimal example you will need to acquire a Google maps browser key as described in Google maps developer's guide. The key may be stored as an application parameter for easy referencing or anywhere you like. All other widget parameters have some sensible default values and may not be configured.
echo $form->field($model, 'coordinates')->widget(
'kolyunya\yii2\widgets\MapInputWidget',
[
// Google maps browser key.
'key' => $key,
]
);
Extended example
An exhaustive list of widget parameters (which are not derived from yii\widgets\InputWidget) available for configuration is described in the following example.
echo $form->field($model, 'coordinates')->widget(
'kolyunya\yii2\widgets\MapInputWidget',
[
// Google maps browser key.
'key' => $key,
// Initial map center latitude. Used only when the input has no value.
// Otherwise the input value latitude will be used as map center.
// Defaults to 0.
'latitude' => 42,
// Initial map center longitude. Used only when the input has no value.
// Otherwise the input value longitude will be used as map center.
// Defaults to 0.
'longitude' => 42,
// jQuery selector for an input where your are going to store your
// latitude value
latitudeSelector = null,
// jQuery selector for an input where your are going to store your
// longitude value
longitudeSelector = null,
// jQuery selector for an input where your are going to save geocoding
// result value
addressSelector = null,
// Initial map zoom.
// Defaults to 0.
'zoom' => 12,
// Map container width.
// Defaults to '100%'.
'width' => '420px',
// Map container height.
// Defaults to '300px'.
'height' => '420px',
// Google map type. See official Google maps reference for details.
// Defaults to 'roadmap'
'mapType' => 'satellite',
// Marker animation behavior defines if a marker should be animated on position change.
// Defaults to false.
'animateMarker' => true,
// Map alignment behavior defines if a map should be centered when a marker is repositioned.
// Defaults to true.
'alignMapCenter' => false,
]
);