PHP code example of lbcdev / map-geometries

1. Go to this page and download the library: Download lbcdev/map-geometries 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 / map-geometries example snippets


use LBCDev\MapGeometries\Marker;

$marker = Marker::make(40.7128, -74.0060, 'New York City')
    ->tooltip('The Big Apple')
    ->iconColor('blue')
    ->icon('custom-icon');

use LBCDev\MapGeometries\MarkerCollection;

$markers = new MarkerCollection();

$markers->add(
    Marker::make(40.7128, -74.0060, 'New York')
);

$markers->add(
    Marker::make(51.5074, -0.1278, 'London')
);

// Iterate
foreach ($markers as $marker) {
    echo $marker->getLabel();
}

// Count
echo count($markers); // 2

// Access by index
$firstMarker = $markers[0];

Marker::make(float $latitude, float $longitude, ?string $label = null): self

use LBCDev\MapGeometries\Marker;
use Livewire\Component;

class MapComponent extends Component
{
    public Marker $marker;
    
    public function mount()
    {
        $this->marker = Marker::make(40.7128, -74.0060, 'NYC');
    }
    
    public function updateMarker()
    {
        $this->marker->iconColor('red');
    }
}