Giter Club home page Giter Club logo

laravel-geocode's Introduction

laravel-geocode

stars issues forks license Total Downloads

Laravel Package to get Lat and Long from Specific Address.

Table of contents

Installation

composer require salmanzafar/laravel-geocode

Configuration

Publish the configuration file

php artisan vendor:publish --provider="Salman\GeoCode\GeoCodeServiceProvider"

Config/geocode.php

'API_KEY' => env('GOOGLE_GEOCODE_API_KEY', ''),

Enable the package (Optional)

This package implements Laravel auto-discovery feature

Usage

You need a Google map geocode api key in order to use this

Finding Coordinates

use Salman\GeoCode\Services\GeoCode;

public function lookForPoints()
{
        $address = "1600 Amphitheatre Parkway,Mountain View";
        $getPoints = new GeoCode();
        return $getPoints->getLatAndLong($address); 
}

Finding Coordinates using Facade

use GeoCode;

public function lookForPoints()
{
    $address = "1600 Amphitheatre Parkway,Mountain View";
    return GeoCode::getLatAndLong($address); 
}

Finding Coordinates using Helper Function

public function lookForPoints()
{
    $address = "1600 Amphitheatre Parkway,Mountain View";
    return findAddressCoordinates($address); 
}

Response

It will return a Laravel collection as response
{
    "address_components": [
        {
            "long_name": "1600",
            "short_name": "1600",
            "types": [
                "street_number"
            ]
        },
        {
            "long_name": "Amphitheatre Parkway",
            "short_name": "Amphitheatre Pkwy",
            "types": [
                "route"
            ]
        },
        {
            "long_name": "Mountain View",
            "short_name": "Mountain View",
            "types": [
                "locality",
                "political"
            ]
        },
        {
            "long_name": "Santa Clara County",
            "short_name": "Santa Clara County",
            "types": [
                "administrative_area_level_2",
                "political"
            ]
        },
        {
            "long_name": "California",
            "short_name": "CA",
            "types": [
                "administrative_area_level_1",
                "political"
            ]
        },
        {
            "long_name": "United States",
            "short_name": "US",
            "types": [
                "country",
                "political"
            ]
        },
        {
            "long_name": "94043",
            "short_name": "94043",
            "types": [
                "postal_code"
            ]
        }
    ],
    "formatted_address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
    "geometry": {
        "location": {
            "lat": 37.4220579,
            "lng": -122.0840897
        },
        "location_type": "ROOFTOP",
        "viewport": {
            "northeast": {
                "lat": 37.42340688029149,
                "lng": -122.0827407197085
            },
            "southwest": {
                "lat": 37.4207089197085,
                "lng": -122.0854386802915
            }
        }
    },
    "place_id": "ChIJtYuu0V25j4ARwu5e4wwRYgE",
    "plus_code": {
        "compound_code": "CWC8+R9 Mountain View, CA, USA",
        "global_code": "849VCWC8+R9"
    },
    "types": [
        "street_address"
    ]
}

laravel-geocode's People

Contributors

salmanzafar40 avatar salmanzafar949 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  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.