Plugin for leaflet extension
Plugin for yii2 based on the Leaflet.PolylineMeasure to measure distances of simple lines as well as of complex polylines, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist yankovskiy/yii2-leaflet-polyline-measure-plugin "0.1.1"
or add, (*4)
"yankovskiy/yii2-leaflet-polyline-measure-plugin": "0.1.1"
to the require section of your composer.json
file., (*5)
Usage
Once the extension is installed, simply use it in your code by :, (*6)
$center = new dosamigos\leaflet\types\LatLng(['lat' => 43.105620, 'lng' => 131.873530]);
$osmLayer = new \dosamigos\leaflet\layers\TileLayer([
'urlTemplate' => 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
'clientOptions' => [
'attribution' => '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
],
]);
$polylineMeasure = new \neverdark\leaflet\PolylineMeasure();
$leaflet = new \dosamigos\leaflet\LeafLet([
'center' => $center, // set the center
]);
$leaflet->addLayer($osmLayer);
$leaflet->installPlugin($polylineMeasure);
echo \dosamigos\leaflet\widgets\Map::widget(['height' => '700px', 'leafLet' => $leaflet]);