Giter Club home page Giter Club logo

google-embed-php's Introduction

Google Embed PHP

Build Status codecov GitHub issues Packagist Packagist Pre Release GitHub license

Use the Embed API of Google Maps with PHP

Requirement

To use this library you must have at least PHP 7.0.

Installation

The Google Embed can be installed with Composer. Run this command:

composer require frolki1_dev/google-embed-php

Usage

To use this library you must have an api key. You can get the free version because you can use the embed api for free.

use Frolki1_Dev\GoogleEmbedMap;

$maps = new GoogleEmbedMap(<Add here your api key>);

// Create a direction map
$direction = $maps->createDirectionsMap();

// Create a place map
$place = $maps->createPlaceMap();

// Crsate a search map
$search = $maps->createSearchMap();

// Create a view map
$view = $maps->createViewMap();

Options

You have the following options in every map type:

// Set a location (street, location, place)
$mapType->setLocation(<string>);

// Set the center of the view (latitude and longitude)
$mapType->setCenter(<float>, <float>);

// Set the zoom factor (0 - 21, 0 = Whole world, 21 = A single building)
$mapType->setZoom(<int>);

// Define the UI language
$mapType->setLanguage(<string>);

// Show the map as a road map
$mapType->useRoadMap();

// Show the map as a satellite map
$mapType->useSatelliteMap();

// Get the source (url)
$mapType->getSource();

// Build a iframe
$mapType->getIFrame();

Direction options

The direction map has also the options and the following methods:

// How the method setLocation but only the start point
$direction->start(<string>);

// Same how method start but only the destination point
$direction->destination(<string>);

// Add waypoints (Can be multiple called)
$direction->addWayPoint(<string>);

// Calculate the route with the car
$direction->drivingMode();

// Calculate the route with walking
$direction->walkingMode();

// Calculate the route with biking
$direction->bicyclingMode();

// Calclate the route with flying
$direction->flyingMode();

// Avoid tolls
$direction->avoidTolls();

// Avoid Ferry
$direction->avoidFerries();

// Avoid Highway
$dircetion->avoidHighways();

// Use the metric unit
$direction->useMetricUnit();

// Use the imperial unit
$direction->useImperialUnit();

License

This library is an open source project and is licensed under the MIT license.

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.