Plugin for yii2 based on the Leaflet.PolylineMeasure to measure distances of simple lines as well as of complex polylines
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yankovskiy/yii2-leaflet-polyline-measure-plugin "0.1.1"
or add
"yankovskiy/yii2-leaflet-polyline-measure-plugin": "0.1.1"
to the require section of your composer.json
file.
Once the extension is installed, simply use it in your code by :
$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]);