Git Product home page Git Product logo

laravel-google-static-map's Introduction

Google Static Map Generator

Generate static map using Google Map API in Laravel.

Total Downloads Latest Stable Version Latest Unstable Version License

Installation in Laravel 5.5 and up

$ composer require mastani/laravel-google-static-map

The package will automatically register itself.

Installation in Laravel 5.4

$ composer require mastani/laravel-google-static-map

Next up, the service provider must be registered:

// config/app.php

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

Installation without Laravel

Another way is install the component through composer.

Either run

$ composer require mastani/laravel-google-static-map

or add

"mastani/laravel-google-static-map": "dev-master"

to the require section of your composer.json.

Usage

$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

Function

Function Description
setSecret(secret) Set signing secret key.
setCenter(location) Set map center with address.
setCenterLatLng(latitude, longitude) Set map center with latitude and longitude.
setZoom(zoom) Set map zoom.
setScale(scale) Set map scale.
setSize(width, height) Set map size.
setMapType(type as MapType) Set map type.
setMapId(id) Set a map ID previously created in Cloud Console.
setFormat(format as Format) Set map format.
addMarker(center, label, color, size) Add marker to map.
addMarkerLatLng(latitude, longitude, label, color, size) Add marker to map with latitude and longitude.
addMarkerWithIcon(center, icon, shadow) Add custom marker to map.
addMarkerLatLngWithIcon(latitude, longitude, icon, shadow) Add marker to map with latitude and longitude.
make() Make url string.
download($path = 'current path', $name_length = 10) Download map image in provided path.

License

The MIT License (MIT). Please see License File for more information.

laravel-google-static-map's People

Contributors

cyrillkalita avatar josefbehr avatar laravel-shift avatar madbob avatar mastani avatar michaeldyrynda avatar mwasper avatar xewl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

laravel-google-static-map's Issues

Composer 2.0 non-compliant vendor namespace

Upon recent upgrade to composer stable channel 2, I started to get errors about missing classes;

Class 'mastani\GoogleStaticMap\GoogleStaticMap' not found
Class 'mastani\GoogleStaticMap\Format' not found

When downgraded to composer stable channel 1 (composer self --1) the errors went away.

Suggestion: update vendor prefix to TitleCase.
Do you want me to open a PR, @mastani ?

Add polygon path support

I would like to be able to draw a polygon or line on the map which is possible with the standard static maps API.

I'm happy to write the method into the class and do a PR if you would accept. Would rather contribute than just fork and forget.

Essentially the consuming dev would feed in a GeoJSON array of lat,long pairs which correspond to the points of the polygon. We could also allow for the insertion using WKT strings like POLYGON.

If you are happy, say the word and i'll PR.

Laravel v6.0 Support

It's not possible to install this package on a Laravel v6.0 project, as the Composer dependencies require "illuminate/contracts": "5.*" and "illuminate/support": "5.*".

Support for Laravel 11

The package seems works perfectly in Laravel 11. It just needs support in composer.json.

    "require": {
        "illuminate/contracts": "5.*|6.*|7.*|8.*|^9.0|^10.0|^11",
        "illuminate/support": "5.*|6.*|7.*|8.*|^9.0|^10.0|^11"
    },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.