PHP code example of bagusindrayana / laravel-maps

1. Go to this page and download the library: Download bagusindrayana/laravel-maps 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/ */

    

bagusindrayana / laravel-maps example snippets


    'providers'=>[
        //....

        Bagusindrayana\LaravelMaps\LaravelMapsServiceProvider::class,

        //...
    ],
    

$map = LaravelMaps::leaflet('map')
->setView([51.505, -0.09], 13);

return view('your-view',compact('map'));

//'map' is variable name will be use in javascript code
$map = LaravelMaps::leaflet('map')
->setView([51.505, -0.09], 13)
->addMarker(function(LeafletMarker $marker){
    return $marker
    ->latLng([51.5, -0.09])
    ->bindPopup('<b>Hello world!</b><br>I am a popup.');
})
->addCircle(function(LeafletCircle $circle){
    return $circle
    ->latLng([51.508, -0.11])
    ->options([
        'radius'=>500,
        'color'=>'red',
        'fillColor'=>'#f03',
        'fillOpacity'=>0.5
    ])
    ->bindPopup("I am a circle.");
})
->addPolygon(function(LeafletPolygon $polygon){
    return $polygon
    ->latLng([
        [51.509, -0.08],
        [51.503, -0.06],
        [51.51, -0.047]
    ])
    ->bindPopup("I am a polygon.");                
})
->addPopup("I am a standalone popup.",[51.513, -0.09]);

//'map' is variable name will be use in javascript code
$map = LaravelMaps::mapbox('map',[
    "center"=>[106.827293,-6.174465],
    "zoom"=>13,
]);

$map->on('load',function($m){
    $m->addMarker(function(MapboxMarker $marker){
        return $marker
        ->lngLat([51.5, -0.09])
        ->setPopup('<b>Hello world!</b><br>I am a popup.');
    });
});
bash
php artisan vendor:publish --provider=Bagusindrayana\LaravelMaps\LaravelMapsServiceProvider