1. Go to this page and download the library: Download sjaakp/yii2-locator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sjaakp / yii2-locator example snippets
use sjaakp\locator\Locator;
/**
* @var app\models\Tower $model
*/
$map = Locator::begin([
'height' => 480,
// ... other options ...
]);
$map->modelCenter($model, 'mapcenter'); // set the map's center
$map->modelZoom($model, 'mapzoom'); // set the map's zoom level
$map->modelFeature($model, 'location'); // place a marker at the tower's location
Locator::end();
use sjaakp\locator\Locator;
/**
* @var yii\data\ActiveDataProvider $dataProvider
*/
$map = Locator::begin([
'leafletOptions' => [
'center' => [48.8, 2.3], // Paris
'zoom' => 5,
// ... more options ...
],
]);
$map->modelFeatures($dataProvider, 'location'); // provide the tower locations
Locator::end();
use yii\widgets\ActiveForm;
use sjaakp\locator\Locator;
/**
* @var app\models\Tower $model
*/
$form = ActiveForm::begin();
$map = Locator::begin([
// ... Locator options ...
]);
$map->activeCenter($model, 'mapcenter'); // allow the map's center to be changed
$map->activeZoom($model, 'mapzoom'); // allow the map's zoom level to be changed
$map->activeMarker($model, 'location'); // allow the model's location to be changed
$map->finder(); // add an interactive Search control to the map
Locator::end();