yii2 location picker
yii2 location picker, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist pavle/yii2-location-picker "*"
or add, (*4)
"pavle/yii2-location-picker": "*"
to the require section of your composer.json
file., (*5)
Usage
Once the extension is installed, simply use it in your code by :, (*6)
Location: <input type="text" id="us2-address" style="width: 200px"/>
Radius: <input type="text" id="us2-radius"/>
Lat.: <input type="text" id="us2-lat"/>
Long.: <input type="text" id="us2-lon"/>
<?= $form->field($model, 'coordinates')->widget(LocationPicker::className(), [
'id' => 'input-coordinates',
'pattern' => '%longitude%,%latitude%',
'pluginOptions' => [
'location' => [
'latitude' => $model->getLatitude(),
'longitude' => $model->getLongitude(),
],
'inputBinding' => [
'latitudeInput' => new JsExpression("$('#us2-lat')"),
'longitudeInput' => new JsExpression("$('#us2-lon')"),
'radiusInput' => new JsExpression("$('#us2-radius')"),
'locationNameInput' => new JsExpression("$('#us2-address')"),
],
'enableAutocomplete' => true,
],
]) ?>