-
Notifications
You must be signed in to change notification settings - Fork 27
Setting control layers #46
Description
I am trying to add tilelayers combined with the Markercluster plugin.
This is working and provided as documentation:
...
use dosamigos\leaflet\layers\TileLayer;
use dosamigos\leaflet\controls\Layers;
...
$center = new LatLng(['lat' => (float)$latitude, 'lng' => (float)$longitude]);
$openstreet = new TileLayer([
'urlTemplate' => 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
'clientOptions' => [
'© OpenStreetMap contributors'
]
]);
$arogis = new TileLayer([
'urlTemplate' => 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
'clientOptions' => [
'© OpenStreetMap contributors'
]
]);
$baseLayers = new Layers();
$baseLayers->setBaseLayers(['Card' => $openstreet, 'Photo' => $arogis]);
$leaflet = new LeafLet([
'tileLayer' => $openstreet,
'center' => $center,
'zoom'=> 13,
]);
$leaflet
->setControls([$baseLayers]);
Adding Markercluster works also.
$cluster = new MarkerCluster([
'url' => Url::to(['you rur lreturning json']),
]);
and changing $leaflet to:
$leaflet
->setControls([$baseLayers]);
$leaflet
->installPlugin($cluster);
Do to:
a. Setting grouplayers
b. Combining groupslayer control and MarkerCluster.