PHP code example of mastani / laravel-google-static-map

1. Go to this page and download the library: Download mastani/laravel-google-static-map 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/ */

    

mastani / laravel-google-static-map example snippets


// config/app.php

'providers' => [
    ...
    Mastani\GoogleStaticMap\GoogleStaticMapServiceProvider::class,
];

$map = new \Mastani\GoogleStaticMap\GoogleStaticMap('Place google map API key or leave it empty');
$url = $map->setCenter('Tehran')
           ->setMapType(\Mastani\GoogleStaticMap\MapType::RoadMap)
           ->setZoom(14)
           ->setSize(600, 600)
           ->setFormat(\Mastani\GoogleStaticMap\Format::JPG)
           ->addMarker('Tehran', '1', 'red', \Mastani\GoogleStaticMap\Size::Small)
           ->addMarkerLatLng(35.6907488, 51.3919293, '1', 'red', \Mastani\GoogleStaticMap\Size::Small)
           ->make(); // Return url contain map address.
           // or
           ->download($path); // Download map image