Coder Social home page Coder Social logo

edutrul / php-geocode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ckdarby/php-geocode

0.0 2.0 0.0 50 KB

A wrapper around Google's Geocoding API to get different details such as latitude, longitude, country, city, district, postcode, town and street number regarding some specific address.

License: MIT License

PHP 100.00%

php-geocode's Introduction

PHP Geocode

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version

A wrapper around the Google Geocoding API to get different details regarding an address such as

  • Latitude/longitude
  • Country
  • City
  • District
  • Postcode
  • Town
  • Street number

Requirement

PHP >= 5.4.0 and curl enabled server.

Installation

You can install the library using the following ways

Composer

The recommended installation method is through Composer, a dependency manager for PHP. Just add kamranahmedse/php-geocode to your project's composer.json file:

{
    "require": {
        "kamranahmedse/php-geocode": "*"
    }
}

and then run composer install. For further details you can find the package at Packagist.

Manual way

Or you can install the package manually by:

  • Copy src/php-geocode.php to your codebase, perhaps to the vendor directory.
  • Add the Geocode class to your autoloader or require the file directly.

Getting Started

I'm going to use the following address to explain the use of library i.e.

1600 Amphitheatre Parkway, Mountain View, CA

Instantiate the Geocode class and call the methods as follows

// Introduce the class into your scope
use KamranAhmed\Geocode\Geocode;


// Optionally you can pass the API key for Geocoding
$geocode = new Geocode();

// Get the details for the passed address
$location = $geocode->get("1600 Amphitheatre Parkway, Mountain View, CA");

// Note: All the functions below accept a parameter as a default value that will be return if the reuqired value isn't found
$location->getAddress( 'default value' ); 
$location->getLatitude(); // returns the latitude of the address
$location->getLongitude(); // returns the longitude of the address
$location->getCountry(); // returns the country of the address
$location->getLocality(); // returns the locality/city of the address
$location->getDistrict(); // returns the district of the address
$location->getPostcode(); // returns the postal code of the address
$location->getTown(); // returns the town of the address
$location->getStreetNumber(); // returns the street number of the address

Feedback

I'd love to hear what you have to say. Please open an issue for any feature requests that you may want or the bugs that you notice. Also you can contact me at [email protected] or you can also find me at twitter @kamranahmed_se

Note

It should be noted that, the Google Geocoding API has the following limits in place and you should keep them in mind before using this wrapper:

  • 2,500 requests per 24 hour period.
  • 5 requests per second.

php-geocode's People

Contributors

kamranahmedse avatar ckdarby avatar iannsp avatar bennyt2 avatar bitdeli-chef avatar

Watchers

James Cloos avatar Eduardo Telaya avatar

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.