### addMarkerWithIcon usage example Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Usage example for addMarkerWithIcon with an address, custom icon URL, and shadow enabled. ```php $map->addMarkerWithIcon('Meydan-e Azadi, Tehran', 'http://example.com/pin.png', true); ``` -------------------------------- ### Install package for Laravel 5.5+ Source: https://github.com/mastani/laravel-google-static-map/blob/master/README.md Install the package for Laravel 5.5 and up. The package will automatically register itself. ```bash $ composer require mastani/laravel-google-static-map ``` -------------------------------- ### addMarker usage examples Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Usage examples for addMarker. The first call specifies a small size using the Size::Small constant. The second call omits the size parameter, defaulting to medium size. ```php $map->addMarker('Tehran', '1', 'red', \Mastani\GoogleStaticMap\Size::Small); // size omitted -> default medium $map->addMarker('Paris', 'A', 'blue'); ``` -------------------------------- ### addMarkerLatLng usage example Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Usage example for addMarkerLatLng with coordinates for Tehran, label '1', red color, and small size. ```php $map->addMarkerLatLng(35.6907488, 51.3919293, '1', 'red', \Mastani\GoogleStaticMap\Size::Small); ``` -------------------------------- ### Install and register service provider for Laravel 5.4 Source: https://github.com/mastani/laravel-google-static-map/blob/master/README.md Install the package for Laravel 5.4 and then register the service provider in config/app.php. ```bash $ composer require mastani/laravel-google-static-map ``` ```php // config/app.php 'providers' => [ ... Mastani\GoogleStaticMap\GoogleStaticMapServiceProvider::class, ]; ``` -------------------------------- ### Facade Usage Example Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapFacade.md Shows how to use the facade via the alias 'GoogleStaticMap' to build a static map URL. ```APIDOC ## Facade Usage Example ### Description Demonstrates using the facade through the alias `GoogleStaticMap` to set the center and zoom and generate a map URL. ### Example ```php use GoogleStaticMap; $url = GoogleStaticMap::setCenter('Tehran') ->setZoom(15) ->make(); ``` ``` -------------------------------- ### addMarkerLatLngWithIcon usage example Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Usage example for addMarkerLatLngWithIcon with coordinates, custom icon URL, and shadow disabled. ```php $map->addMarkerLatLngWithIcon(35.6907488, 51.3919293, 'http://example.com/pin.png', false); ``` -------------------------------- ### Basic download() example Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Basic usage of download() with default parameters. The returned path is formatted as realpath($path)/., where the random name is 10 characters long and the extension comes from the current format (here .jpg from Format::JPG). ```php $savedPath = $map->setCenter('Tehran')->download(); // e.g. '/var/www/app/1Xk8qTmV3a.jpg' (10-char name, '.jpg' from Format::JPG) ``` -------------------------------- ### Laravel container resolution example Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapServiceProvider.md Shows container resolution: both app('google-static-map') and the class name return the same singleton. The example then uses the instance to set a center and generate a URL. ```php // Both lookups return the same singleton instance: $mapA = app('google-static-map'); $mapB = \Mastani\GoogleStaticMap\GoogleStaticMap::class; // via container make() $url = $mapA->setCenter('Tehran')->make(); ``` -------------------------------- ### setCenter usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Examples of setting the center with an address string. ```php $map->setCenter('Tehran'); // or a street address: $map->setCenter('Tajrish Square, Tehran, Iran'); ``` -------------------------------- ### Guarding the shared singleton example Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapServiceProvider.md Warns about state leakage in the shared singleton. After setting center/zoom, the same instance retains that state; to get a clean builder, construct a new GoogleStaticMap with an API key. ```php // Because the container instance is shared and keyless, a re-entrant // configuration leak is possible; clone-state or reset before reuse: $map = app('google-static-map'); $url1 = $map->setCenter('Tehran')->setZoom(14)->make(); // After this call the same singleton still carries center/zoom state; // the marker/state list is only cleared by constructing a new instance. $fresh = new \Mastani\GoogleStaticMap\GoogleStaticMap('KEY'); // isolated builder ``` -------------------------------- ### setSecret usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Example of setting the signing secret. ```php $map->setSecret('kYj5VZ3pY1VbyqsbY...'); // signing secret issued with your API key ``` -------------------------------- ### Install package without Laravel Source: https://github.com/mastani/laravel-google-static-map/blob/master/README.md Install the package without Laravel using Composer, either by running the command or adding the package to the require section of composer.json. ```bash $ composer require mastani/laravel-google-static-map ``` ```json "mastani/laravel-google-static-map": "dev-master" ``` -------------------------------- ### setCenterLatLng usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Example of setting the center with coordinates, showing the resulting URL parameter. ```php $map->setCenterLatLng(35.6907488, 51.3919293); // -> '¢er=35.6907488,51.3919293' ``` -------------------------------- ### download($path = '.'.DIRECTORY_SEPARATOR, $name_length = 10) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Documentation for the download method of the GoogleStaticMap class, including parameters, return value, and usage examples. ```APIDOC ## download($path = '.'.DIRECTORY_SEPARATOR, $name_length = 10) ### Description Downloads the generated static map image to a specified directory with a random filename. ### Method `download` ### Signature ```php public function download($path = '.'.DIRECTORY_SEPARATOR, $name_length = 10) ``` ### Parameters - **$path** (string) - Optional - Default: `'.' . DIRECTORY_SEPARATOR` (current directory). Existing directory the image is written to. The source calls `realpath($path)` and `rtrim(..., DIRECTORY_SEPARATOR)` before appending the filename, so the path must resolve to a real directory. - **$name_length** (int) - Optional - Default: `10`. Length of the random alphanumeric filename prefix (excluding the extension). ### Returns - **string** - The full path of the written file, formatted as `realpath($path)/.` where `` comes from `generateRandomString($name_length)` and the extension is the current `format`. ### Throws None declared. Note the source performs no error handling around `file_get_contents($url)` / `file_put_contents($path, $content)`; a failed HTTP request or unwritable directory will surface as PHP warnings/errors from those built-in functions. ### Example — basic ```php $savedPath = $map->setCenter('Tehran')->download(); // e.g. '/var/www/app/1Xk8qTmV3a.jpg' (10-char name, '.jpg' from Format::JPG) ``` ### Example — custom directory and filename length ```php $savedPath = $map->setFormat(\Mastani\GoogleStaticMap\Format::PNG) ->download('/tmp/images', 16); // e.g. '/tmp/images/9sJdnN4QbVcZkD2f.png' ``` ``` -------------------------------- ### Generate basic static map URL with make() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Basic usage of the make() method to generate a static map URL. The example chains setters for center, map type, zoom, size, format, and a marker, then calls make(). The resulting URL is shown in the comment. ```php $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) ->make(); // https://maps.googleapis.com/maps/api/staticmap?center=Tehran&zoom=14&size=600x600&maptype=roadmap&format=jpg&visual_refresh=true&markers=size:tiny%7Ccolor:red%7Clabel:1%7CTehran ``` -------------------------------- ### Generate static map URL or download image Source: https://github.com/mastani/laravel-google-static-map/blob/master/README.md Create a GoogleStaticMap instance with an API key, chain methods to set center, map type, zoom, size, format, and markers, then call make() to get the URL or download() to save the image. ```php $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 ``` -------------------------------- ### register() body: singleton and alias Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapServiceProvider.md Registers GoogleStaticMap as a singleton with no API key, and aliases it to 'google-static-map'. This matches the facade accessor. Consumers get the same shared instance; configure it via setSecret()/setCenter() or construct a new instance with a key. ```php $this->app->singleton(GoogleStaticMap::class, function () { return new GoogleStaticMap(); }); $this->app->alias(GoogleStaticMap::class, 'google-static-map'); ``` -------------------------------- ### Resolving the 'google-static-map' binding Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapFacade.md Example of resolving the container binding directly using the app() helper. The comment shows the alias created in the service provider's register() method. ```php // register() creates: $this->app->alias(GoogleStaticMap::class, 'google-static-map'); $map = app('google-static-map'); // -> the shared GoogleStaticMap singleton ``` -------------------------------- ### Service provider bindings for GoogleStaticMap Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/configuration.md Hard-coded bindings in the service provider's register() method. The singleton is created without an API key, so the resolved instance always starts with apiKey = ''. ```php $this->app->singleton(GoogleStaticMap::class, function () { return new GoogleStaticMap(); // singleton created WITHOUT an API key }); $this->app->alias(GoogleStaticMap::class, 'google-static-map'); ``` -------------------------------- ### Laravel usage with the GoogleStaticMap alias Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapFacade.md Example of using the facade via the alias declared in composer.json. The static call is dispatched to the container binding, and the builder methods are chained to generate a URL. ```php // composer.json declares: "aliases": { "GoogleStaticMap": "Mastani\\GoogleStaticMap\\GoogleStaticMapFacade" } use GoogleStaticMap; $url = GoogleStaticMap::setCenter('Tehran') ->setZoom(15) ->make(); ``` -------------------------------- ### boot() method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapServiceProvider.md The boot() method takes no arguments, returns void, and has an empty body. It performs no boot-time work. ```php public function boot() ``` -------------------------------- ### Basic constructor usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Basic instantiation with an API key. ```php $map = new \Mastani\GoogleStaticMap\GoogleStaticMap('YOUR_GOOGLE_API_KEY'); ``` -------------------------------- ### Constructor Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Initializes the builder with an API key and optional secret. ```APIDOC ## Constructor ### Description Creates a new GoogleStaticMap instance with the given API key and optional secret. ### Method Constructor ### Parameters - **apiKey** (string) - Required - The Google Maps API key. - **apiSecret** (string) - Optional - The signing secret for URL authentication. ### Request Example ```php $map = new GoogleStaticMap('YOUR_API_KEY', 'YOUR_SECRET'); ``` ``` -------------------------------- ### make() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Documentation for the make() method of the GoogleStaticMap class, which generates the full static map URL. ```APIDOC ## make() ### Description Generates the full Google Static Map URL based on the configured parameters. The URL is always prefixed by `https://maps.googleapis.com` and starts with the path `/maps/api/staticmap?`. ### Method `make()` ### Signature ```php public function make(): string ``` ### Parameters None. ### Returns - **string** - The full map URL. ### URL Assembly Order 1. `key=` - only if API key is set 2. `center=` - only if center is set 3. `zoom=` - only if zoom is not 0 4. `scale=` - only if scale is not 0 5. `size=` - always (default `'600x300'`) 6. `maptype=` - always (default `MapType::RoadMap`) 7. `map_id=` - only if map ID is set 8. `format=` - always (default `Format::JPG`) 9. `visual_refresh=true` - always 10. `markers=` - one per marker 11. `signature=` - appended when API secret is set ### Example - Basic ```php $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) ->make(); // https://maps.googleapis.com/maps/api/staticmap?center=Tehran&zoom=14&size=600x600&maptype=roadmap&format=jpg&visual_refresh=true&markers=size:tiny%7Ccolor:red%7Clabel:1%7CTehran ``` ### Example - With Signing Secret ```php $url = $map->setCenterLatLng(35.6907488, 51.3919293) ->setSecret('YOUR_URL_SIGNING_SECRET') ->make(); // ...&signature=Bc-K1wL9S9j94nnQ0c0x1R... (URL-safe base64 HMAC-SHA1) ``` ``` -------------------------------- ### Constructor without key and Laravel container usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Instantiation without a key, and retrieval via the Laravel container. ```php // Without a key (the URL will omit the 'key' parameter) $map = new \Mastani\GoogleStaticMap\GoogleStaticMap(); // Inside Laravel, the container returns the configured singleton: $map = app('google-static-map'); ``` -------------------------------- ### download() method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Method signature for downloading the generated static map image. The path must resolve to a real directory because the source calls realpath() and rtrim() before appending the filename. No error handling is performed around file_get_contents() or file_put_contents(), so failures surface as PHP warnings or errors. ```php public function download($path = '.'.DIRECTORY_SEPARATOR, $name_length = 10) ``` -------------------------------- ### register() method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapServiceProvider.md The register() method takes no arguments and returns void. Its body is shown in the next snippet. ```php public function register() ``` -------------------------------- ### make() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Generates the Google Static Maps API URL. ```APIDOC ## make() ### Description Generates the Google Static Maps API URL based on the accumulated parameters. ### Method make ### Parameters None ### Returns - **string** - The full URL to the Google Static Maps API. ### Request Example ```php $url = $map->make(); ``` ### Response Example ``` https://maps.googleapis.com/maps/api/staticmap?center=...&zoom=15&size=600x300&maptype=roadmap&format=jpg&key=YOUR_API_KEY ``` ``` -------------------------------- ### download() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Downloads the map image to a specified file path. ```APIDOC ## download() ### Description Downloads the map image to the specified file path. ### Method download ### Parameters - **path** (string) - Required - The file path where the image will be saved. ### Returns - **bool** - True on success, false on failure. ### Request Example ```php $map->download('/path/to/map.jpg'); ``` ``` -------------------------------- ### __construct($apiKey = '') Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Creates a new GoogleStaticMap instance. Optionally accepts a Google Static Maps API key. If no key is provided, the generated URL will omit the 'key' parameter. ```APIDOC ## Constructor ### `__construct($apiKey = '')` **Description:** Creates a new GoogleStaticMap instance. Optionally accepts a Google Static Maps API key. If no key is provided, the generated URL will omit the 'key' parameter. **Method:** Constructor **Signature:** `public function __construct($apiKey = '')` **Parameters:** - `$apiKey` (string) - Optional - Google Static Maps API key. Defaults to `''`. **Returns:** The constructed instance (`$this`). **Throws:** None. **Example:** ```php $map = new \Mastani\GoogleStaticMap\GoogleStaticMap('YOUR_GOOGLE_API_KEY'); ``` **Example (no key / via Laravel container):** ```php // Without a key (the URL will omit the 'key' parameter) $map = new \Mastani\GoogleStaticMap\GoogleStaticMap(); // Inside Laravel, the container returns the configured singleton: $map = app('google-static-map'); ``` ``` -------------------------------- ### Composer autoload for Mastani\GoogleStaticMap Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/configuration.md Composer PSR-4 autoload configuration mapping the Mastani\GoogleStaticMap namespace to the src/ directory. ```json "autoload": { "psr-4": { "Mastani\\GoogleStaticMap\\": "src/" } } ``` -------------------------------- ### setFormat() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the image format (e.g., png, jpg, gif). ```APIDOC ## setFormat() ### Description Sets the image format (e.g., png, jpg, gif). ### Method setFormat ### Parameters - **format** (string) - Required - Format constant or string. ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->setFormat('png'); ``` ``` -------------------------------- ### setFormat($format) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the image format. The value is emitted as `format=`. Also used by `download()` as the filename extension. ```APIDOC ## setFormat($format) ### Description Sets the image format. The value is emitted as `format=`. Also used by `download()` as the filename extension. ### Method setFormat ### Signature `public function setFormat($format)` ### Parameters - **$format** (string) - Required - One of the `Format` constants: `Format::JPG`, `Format::PNG`, `Format::GIF`. Default is `Format::JPG`. ### Returns `$this` (fluent) ### Example ```php $map->setFormat(\Mastani\GoogleStaticMap\Format::PNG); ``` ``` -------------------------------- ### setSize($width, $height) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the size of the map image in pixels. The size is stored as `widthxheight` and emitted as `size=`. ```APIDOC ## setSize($width, $height) ### Description Sets the size of the map image in pixels. The size is stored as `widthxheight` and emitted as `size=`. ### Method setSize ### Signature `public function setSize($width, $height)` ### Parameters - **$width** (int) - Required - Width in pixels. Default is `600`. - **$height** (int) - Required - Height in pixels. Default is `300`. ### Returns `$this` (fluent) ### Example ```php $map->setSize(600, 600); // -> '&size=600x600' ``` ``` -------------------------------- ### setSize method and usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the map size in pixels. The width and height are stored as `widthxheight` and emitted as `size=`. Defaults are `600` and `300`. Returns `$this` for fluent chaining. ```php public function setSize($width, $height) ``` ```php $map->setSize(600, 600); // -> '&size=600x600' ``` -------------------------------- ### Constructor signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Constructor for the GoogleStaticMap class. Accepts an optional API key; an empty string omits the 'key' query parameter from requests. ```php public function __construct($apiKey = '') ``` -------------------------------- ### Custom directory and filename length download() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Downloads the map to a custom directory with a longer random filename prefix. The format is set to PNG and the filename length is 16 characters, producing a path like '/tmp/images/9sJdnN4QbVcZkD2f.png'. ```php $savedPath = $map->setFormat(\Mastani\GoogleStaticMap\Format::PNG) ->download('/tmp/images', 16); // e.g. '/tmp/images/9sJdnN4QbVcZkD2f.png' ``` -------------------------------- ### setCenterLatLng signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Method signature for setting the center using latitude and longitude, concatenated into 'center=lat,lng'. ```php public function setCenterLatLng($latitude, $longitude) ``` -------------------------------- ### addMarker Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Adds a simple marker to the map using an address string. ```APIDOC ## addMarker($center, $label, $color, $size = Size::Medium) ### Description Adds a simple marker to the map using an address string as the location. The marker is serialized in the `markers` parameter with size, color, label, and location fields. ### Method PHP method (fluent) ### Signature `public function addMarker($center, $label, $color, $size = Size::Medium)` ### Parameters - **$center** (string) - Required - Location as an address string stored in `location`. - **$label** (string) - Required - Alphanumeric marker label (single character usually). - **$color** (string) - Required - Marker color, e.g. `'red'`. - **$size** (string) - Optional - Default: `Size::Medium` (`'small'`). One of the `Size` constants: `Size::Small` (`'tiny'`), `Size::Medium` (`'small'`), `Size::Large` (`'mid'`). ### Returns `$this` (fluent). ### Example ```php $map->addMarker('Tehran', '1', 'red', \Mastani\GoogleStaticMap\Size::Small); // size omitted -> default medium $map->addMarker('Paris', 'A', 'blue'); ``` ``` -------------------------------- ### signUrl($url) method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Called by make() when apiSecret is set. Decodes the secret (base64_decode after mapping - to +, _ to /), computes HMAC-SHA1 over the URL, then base64-encodes the signature with + to -, / to _ mapping and appends &signature=... Source credit comment references the geocoder-php GoogleMapsBusinessProvider implementation. ```php protected function signUrl($url) ``` -------------------------------- ### getFacadeAccessor method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapFacade.md The getFacadeAccessor method signature. It takes no arguments and returns the container binding key 'google-static-map'. This method is required by every Facade subclass. ```php protected static function getFacadeAccessor() ``` -------------------------------- ### Generate signed static map URL with setSecret() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Generates a signed static map URL using a URL signing secret. The signature is appended by signUrl() only when apiSecret is set and non-empty, producing a URL-safe base64 HMAC-SHA1 signature. ```php $url = $map->setCenterLatLng(35.6907488, 51.3919293) ->setSecret('YOUR_URL_SIGNING_SECRET') ->make(); // ...&signature=Bc-K1wL9S9j94nnQ0c0x1R... (URL-safe base64 HMAC-SHA1) ``` -------------------------------- ### Size constants for marker sizes Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/types.md Defines the Size abstract class with constants for marker sizes. Size::Medium is the default for the $size parameter in addMarker() and addMarkerLatLng(). The constant value is emitted as the size: prefix inside the markers= query segment. ```php // src/Size.php namespace Mastani\GoogleStaticMap; abstract class Size { const Small = 'tiny'; const Medium = 'small'; const Large = 'mid'; } ``` -------------------------------- ### generateRandomString($length = 10) method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Generates a random string of $length characters drawn from 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. Used by download() for the filename. The implementation calls rand(0, $charactersLength - 1) — note the source's own credit comment references a StackOverflow answer; the exact runtime behavior of this rand() call depends on the environment's PHP interpretation and is not defensible from static analysis alone. ```php protected function generateRandomString($length = 10) ``` -------------------------------- ### setCenterLatLng($latitude, $longitude) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the map center using latitude and longitude coordinates. The values are concatenated into 'center=lat,lng'. ```APIDOC ## setCenterLatLng($latitude, $longitude) **Description:** Sets the map center using latitude and longitude coordinates. The values are concatenated into 'center=lat,lng'. **Method:** setCenterLatLng **Signature:** `public function setCenterLatLng($latitude, $longitude)` **Parameters:** - `$latitude` (float) - Required - Latitude. - `$longitude` (float) - Required - Longitude. **Returns:** `$this` (fluent). **Throws:** None. **Example:** ```php $map->setCenterLatLng(35.6907488, 51.3919293); // -> '¢er=35.6907488,51.3919293' ``` ``` -------------------------------- ### Format constants for image formats Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/types.md Abstract constant-holder class defining the supported image formats for the Google Static Map API. The constant values are emitted as the `format=` query parameter and used as the file extension in `download()`. `Format::JPG` is the default for `setFormat()` and the initial `format` state. ```php // src/Format.php namespace Mastani\GoogleStaticMap; abstract class Format { const JPG = 'jpg'; const PNG = 'png'; const GIF = 'gif'; } ``` -------------------------------- ### setFormat method and usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the image format using one of the `Format` constants: `Format::JPG`, `Format::PNG`, or `Format::GIF`. The value is emitted as `format=` and is also used by `download()` as the filename extension. Default is `Format::JPG`. Returns `$this` for fluent chaining. ```php public function setFormat($format) ``` ```php $map->setFormat(\Mastani\GoogleStaticMap\Format::PNG); ``` -------------------------------- ### addMarkerLatLng Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Adds a simple marker to the map using latitude and longitude coordinates. ```APIDOC ## addMarkerLatLng($latitude, $longitude, $label, $color, $size = Size::Medium) ### Description Adds a simple marker to the map using latitude and longitude coordinates. The location is stored as `"lat,lng"`. ### Method PHP method (fluent) ### Signature `public function addMarkerLatLng($latitude, $longitude, $label, $color, $size = Size::Medium)` ### Parameters - **$latitude** (float) - Required - Latitude; stored as `location = "lat,lng"`. - **$longitude** (float) - Required - Longitude. - **$label** (string) - Required - Marker label. - **$color** (string) - Required - Marker color. - **$size** (string) - Optional - Default: `Size::Medium`. One of the `Size` constants. ### Returns `$this` (fluent). ### Example ```php $map->addMarkerLatLng(35.6907488, 51.3919293, '1', 'red', \Mastani\GoogleStaticMap\Size::Small); ``` ``` -------------------------------- ### addMarkerLatLng() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Adds a marker to the map using latitude and longitude coordinates. ```APIDOC ## addMarkerLatLng() ### Description Adds a marker to the map using latitude and longitude coordinates. ### Method addMarkerLatLng ### Parameters - **lat** (float) - Required - Latitude. - **lng** (float) - Required - Longitude. - **label** (string) - Optional - Marker label. - **color** (string) - Optional - Marker color. - **size** (string) - Optional - Marker size. ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->addMarkerLatLng(40.7128, -74.0060, 'A', 'red', 'mid'); ``` ``` -------------------------------- ### setSize() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the dimensions of the map image. ```APIDOC ## setSize() ### Description Sets the dimensions of the map image in pixels (e.g., '600x300'). ### Method setSize ### Parameters - **size** (string) - Required - Size string in format 'WIDTHxHEIGHT'. ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->setSize('800x400'); ``` ``` -------------------------------- ### setZoom method and usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the zoom level for the map. The zoom value is emitted as `zoom=` unless it is `0`. The default is `15`. Returns `$this` for fluent chaining. ```php public function setZoom($zoom) ``` ```php $map->setZoom(14); ``` -------------------------------- ### setZoom($zoom) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the zoom level for the static map. The zoom value is emitted as `zoom=` unless it is `0`. ```APIDOC ## setZoom($zoom) ### Description Sets the zoom level for the static map. The zoom value is emitted as `zoom=` unless it is `0`. ### Method setZoom ### Signature `public function setZoom($zoom)` ### Parameters - **$zoom** (int) - Required - Zoom level. Default is `15`. ### Returns `$this` (fluent) ### Example ```php $map->setZoom(14); ``` ``` -------------------------------- ### addMarkerLatLng method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Signature of the addMarkerLatLng method. Accepts latitude, longitude, label, color, and optional size (default Size::Medium). Returns $this for fluent chaining. ```php public function addMarkerLatLng($latitude, $longitude, $label, $color, $size = Size::Medium) ``` -------------------------------- ### addMarker() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Adds a marker to the map using a textual location. ```APIDOC ## addMarker() ### Description Adds a marker to the map using a textual location. ### Method addMarker ### Parameters - **location** (string) - Required - The location string. - **label** (string) - Optional - Marker label. - **color** (string) - Optional - Marker color. - **size** (string) - Optional - Marker size. ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->addMarker('New York, NY', 'A', 'red', 'mid'); ``` ``` -------------------------------- ### addMarkerLatLngWithIcon method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Signature of the addMarkerLatLngWithIcon method. Accepts latitude, longitude, icon URL, and optional shadow flag (default false). Returns $this for fluent chaining. ```php public function addMarkerLatLngWithIcon($latitude, $longitude, $icon, $shadow = false) ``` -------------------------------- ### addMarkerLatLngWithIcon() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Adds a marker with a custom icon using latitude and longitude coordinates. ```APIDOC ## addMarkerLatLngWithIcon() ### Description Adds a marker with a custom icon using latitude and longitude coordinates. ### Method addMarkerLatLngWithIcon ### Parameters - **lat** (float) - Required - Latitude. - **lng** (float) - Required - Longitude. - **icon** (string) - Required - URL of the custom icon. - **label** (string) - Optional - Marker label. - **color** (string) - Optional - Marker color. - **size** (string) - Optional - Marker size. ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->addMarkerLatLngWithIcon(40.7128, -74.0060, 'https://example.com/icon.png', 'A', 'red', 'mid'); ``` ``` -------------------------------- ### setCenter signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Method signature for setting the map center as an address string, emitted as 'center=' in the URL. ```php public function setCenter($location) ``` -------------------------------- ### addMarkerWithIcon method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Signature of the addMarkerWithIcon method. Accepts a center location, icon URL, and optional shadow flag (default false). Returns $this for fluent chaining. ```php public function addMarkerWithIcon($center, $icon, $shadow = false) ``` -------------------------------- ### getFacadeAccessor() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapFacade.md Returns the container binding key 'google-static-map' that the facade proxies to. This method is required by Laravel's Facade base class. ```APIDOC ## getFacadeAccessor() ### Description Returns the container binding key `'google-static-map'` that the facade proxies to. This method is required by Laravel's Facade base class. ### Method `protected static function getFacadeAccessor()` ### Parameters None. ### Returns - **string** - The container binding key `'google-static-map'`. ### Throws None declared. ### Example ```php // The facade resolves the container binding via this accessor. $map = app('google-static-map'); ``` ``` -------------------------------- ### setCenter($location) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the map center as an address string. The value is emitted as the 'center' parameter in the URL. ```APIDOC ## setCenter($location) **Description:** Sets the map center as an address string. The value is emitted as the 'center' parameter in the URL. **Method:** setCenter **Signature:** `public function setCenter($location)` **Parameters:** - `$location` (string) - Required - Map center as an address string. **Returns:** `$this` (fluent). **Throws:** None. **Example:** ```php $map->setCenter('Tehran'); // or a street address: $map->setCenter('Tajrish Square, Tehran, Iran'); ``` ``` -------------------------------- ### addMarker method signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Signature of the addMarker method. It accepts a center location, label, color, and optional size (default Size::Medium). Returns $this for fluent chaining. ```php public function addMarker($center, $label, $color, $size = Size::Medium) ``` -------------------------------- ### setScale() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the scale factor for the map image. ```APIDOC ## setScale() ### Description Sets the scale factor for the map image (1 or 2). ### Method setScale ### Parameters - **scale** (int|string) - Required - Scale value (default '1'). ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->setScale(2); ``` ``` -------------------------------- ### setCenterLatLng() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the center of the map using latitude and longitude coordinates. ```APIDOC ## setCenterLatLng() ### Description Sets the center of the map using latitude and longitude coordinates. ### Method setCenterLatLng ### Parameters - **lat** (float) - Required - Latitude. - **lng** (float) - Required - Longitude. ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->setCenterLatLng(40.7128, -74.0060); ``` ``` -------------------------------- ### setMapId($mapId) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets a stylized/custom map ID previously created in the Google Cloud Console. The value is emitted as `map_id=` when not `null`. ```APIDOC ## setMapId($mapId) ### Description Sets a stylized/custom map ID previously created in the Google Cloud Console. The value is emitted as `map_id=` when not `null`. ### Method setMapId ### Signature `public function setMapId($mapId)` ### Parameters - **$mapId** (string) - Required - A stylized/custom map ID. Default is `null`. ### Returns `$this` (fluent) ### Example ```php $map->setMapId('enc:your-custom-map-id'); ``` ``` -------------------------------- ### setMapId method and usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets a stylized/custom map ID previously created in the Google Cloud Console. The value is emitted as `map_id=` when not `null`. Default is `null`. Returns `$this` for fluent chaining. ```php public function setMapId($mapId) ``` ```php $map->setMapId('enc:your-custom-map-id'); ``` -------------------------------- ### setZoom() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the zoom level of the map. ```APIDOC ## setZoom() ### Description Sets the zoom level of the map. ### Method setZoom ### Parameters - **zoom** (int) - Required - Zoom level (default 15). ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->setZoom(12); ``` ``` -------------------------------- ### addMarkerWithIcon() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Adds a marker with a custom icon using a textual location. ```APIDOC ## addMarkerWithIcon() ### Description Adds a marker with a custom icon using a textual location. ### Method addMarkerWithIcon ### Parameters - **location** (string) - Required - The location string. - **icon** (string) - Required - URL of the custom icon. - **label** (string) - Optional - Marker label. - **color** (string) - Optional - Marker color. - **size** (string) - Optional - Marker size. ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->addMarkerWithIcon('New York, NY', 'https://example.com/icon.png', 'A', 'red', 'mid'); ``` ``` -------------------------------- ### setCenter() Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the center of the map using a textual location string. ```APIDOC ## setCenter() ### Description Sets the center of the map using a textual location string (e.g., an address or place name). ### Method setCenter ### Parameters - **center** (string) - Required - The location string. ### Returns - **$this** - The current instance for chaining. ### Request Example ```php $map->setCenter('New York, NY'); ``` ``` -------------------------------- ### Class declaration for GoogleStaticMapServiceProvider Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMapServiceProvider.md Declares the GoogleStaticMapServiceProvider class, extending Laravel's ServiceProvider. The class is registered automatically via composer.json's extra.laravel.providers, or manually in config/app.php for Laravel 5.4. ```php // src/GoogleStaticMapServiceProvider.php use Illuminate\Support\ServiceProvider; class GoogleStaticMapServiceProvider extends ServiceProvider ``` -------------------------------- ### setSecret($apiSecret) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the URL-signing secret key. When non-empty, the generated URL will include an HMAC-SHA1 signature. ```APIDOC ## setSecret($apiSecret) **Description:** Sets the URL-signing secret key. When non-empty, the generated URL will include an HMAC-SHA1 signature. **Method:** setSecret **Signature:** `public function setSecret($apiSecret)` **Parameters:** - `$apiSecret` (string) - Required - URL-signing secret key. **Returns:** `$this` (fluent). **Throws:** None. **Example:** ```php $map->setSecret('kYj5VZ3pY1VbyqsbY...'); // signing secret issued with your API key ``` ``` -------------------------------- ### GoogleStaticMap class declaration Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Declares the GoogleStaticMap class at line 5 of src/GoogleStaticMap.php. The class is the fluent builder for the package. ```php // src/GoogleStaticMap.php:5 class GoogleStaticMap ``` -------------------------------- ### addMarkerWithIcon Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Adds a custom icon marker to the map using an address string. ```APIDOC ## addMarkerWithIcon($center, $icon, $shadow = false) ### Description Adds a custom icon marker to the map using an address string as the location. The marker is serialized with an icon URL and optional shadow. ### Method PHP method (fluent) ### Signature `public function addMarkerWithIcon($center, $icon, $shadow = false)` ### Parameters - **$center** (string) - Required - Location as an address string. - **$icon** (string) - Required - URL of the custom icon image. - **$shadow** (bool) - Optional - Default: `false`. Whether to render a shadow on the icon. ### Returns `$this` (fluent). ### Example ```php $map->addMarkerWithIcon('Meydan-e Azadi, Tehran', 'http://example.com/pin.png', true); ``` ``` -------------------------------- ### addMarkerLatLngWithIcon Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Adds a custom icon marker to the map using latitude and longitude coordinates. ```APIDOC ## addMarkerLatLngWithIcon($latitude, $longitude, $icon, $shadow = false) ### Description Adds a custom icon marker to the map using latitude and longitude coordinates. The location is stored as `"lat,lng"`. ### Method PHP method (fluent) ### Signature `public function addMarkerLatLngWithIcon($latitude, $longitude, $icon, $shadow = false)` ### Parameters - **$latitude** (float) - Required - Latitude; stored as `location = "lat,lng"`. - **$longitude** (float) - Required - Longitude. - **$icon** (string) - Required - URL of the custom icon image. - **$shadow** (bool) - Optional - Default: `false`. Whether to render a shadow on the icon. ### Returns `$this` (fluent). ### Example ```php $map->addMarkerLatLngWithIcon(35.6907488, 51.3919293, 'http://example.com/pin.png', false); ``` ``` -------------------------------- ### setSecret signature Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Method signature for setting the URL-signing secret key. When non-empty, make() appends an HMAC-SHA1 signature to the URL. ```php public function setSecret($apiSecret) ``` -------------------------------- ### setScale($scale) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the map scale multiplier. The scale value is emitted as `scale=` unless it is `0`. ```APIDOC ## setScale($scale) ### Description Sets the map scale multiplier. The scale value is emitted as `scale=` unless it is `0`. ### Method setScale ### Signature `public function setScale($scale)` ### Parameters - **$scale** (int) - Required - Map scale multiplier. Default is `'1'` (stored as string). ### Returns `$this` (fluent) ### Example ```php $map->setScale(2); ``` ``` -------------------------------- ### setScale method and usage Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the map scale multiplier. The scale value is emitted as `scale=` unless it is `0`. The default is `'1'` (stored as a string). Returns `$this` for fluent chaining. ```php public function setScale($scale) ``` ```php $map->setScale(2); ``` -------------------------------- ### setMapType($mapType) Source: https://github.com/mastani/laravel-google-static-map/blob/master/_autodocs/api-reference/GoogleStaticMap.md Sets the map type. The value is emitted as `maptype=`. ```APIDOC ## setMapType($mapType) ### Description Sets the map type. The value is emitted as `maptype=`. ### Method setMapType ### Signature `public function setMapType($mapType)` ### Parameters - **$mapType** (string) - Required - One of the `MapType` constants: `MapType::RoadMap`, `MapType::Terrain`, `MapType::Satellite`, `MapType::Hybrid`. Default is `MapType::RoadMap`. ### Returns `$this` (fluent) ### Example ```php $map->setMapType(\Mastani\GoogleStaticMap\MapType::Satellite); ``` ```