1. Go to this page and download the library: Download lbcdev/livewire-maps-core 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/ */
lbcdev / livewire-maps-core example snippets
use LBCDev\MapGeometries\Marker;
$marker = Marker::make(40.7128, -74.0060, 'New York City')
->tooltip('The Big Apple')
->iconColor('blue');
use LBCDev\MapGeometries\Marker;
use LBCDev\MapGeometries\MarkerCollection;
$markers = new MarkerCollection();
$markers->add(
Marker::make(40.7128, -74.0060, 'New York')
->iconColor('blue')
);
$markers->add(
Marker::make(51.5074, -0.1278, 'London')
->iconColor('red')
);
protected $listeners = [
'fly-to-coordinates' => 'flyTo',
];
public function flyTo(array $data)
{
// $data = ['lat' => X, 'lng' => Y, 'zoom' => Z]
}
use Livewire\Component;
use LBCDev\MapGeometries\Marker;
use LBCDev\MapGeometries\MarkerCollection;
class LocationPicker extends Component
{
public ?Marker $selectedLocation = null;
public MarkerCollection $locations;
protected $listeners = [
'map-coordinates-updated' => 'handleLocationSelected'
];
public function mount()
{
$this->locations = new MarkerCollection();
// Add some locations
$this->locations->add(
Marker::make(40.7128, -74.0060, 'New York')
);
}
public function handleLocationSelected($data)
{
$this->selectedLocation = Marker::make(
$data['lat'],
$data['lng'],
'Selected Location'
);
}
public function render()
{
return view('livewire.location-picker');
}
}