2017 © Pedro Pelรกez
 

laravel gaode-maps

This is a php package for Gaode Web Services API

image

imphinite/gaode-maps

This is a php package for Gaode Web Services API

  • Thursday, March 1, 2018
  • by imphinite
  • Repository
  • 0 Watchers
  • 1 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 25 % Grown

The README.md

Collection of Gaode Web Services API for Laravel 5

DEVELOPMENT IN PROGRESS, (*1)

Provides convenient way of setting up and making requests to Gaode Web Services API from Laravel application., (*2)

For services documentation, API key and Usage Limits visit Gaode Web Services API and Gaode Web Services API Usage Limits And Restrictions., (*3)

**Note that this package is under development. Most Features are not implemented yet. Feel free to collaborate on this project!, (*4)

**SPECIAL THANKS TO Alexpechkarev. Web Services Engine is borrowed from Alexpechkarev/google-maps., (*5)

Features

Features TO-DO List

Dependency

Installation

Issue following command in console:, (*6)

composer require imphinite/gaode-maps

Alternatively edit composer.json by adding following line and run composer update, (*7)

"require": { 
        ....,
        "imphinite/gaode-maps",

    },

Configuration

Register package service provider and facade in 'config/app.php', (*8)

'providers' => [
    ...
    'GaodeMaps\ServiceProvider\GaodeMapsServiceProvider',
]

'aliases' => [
    ...
    'GaodeMaps' => 'GaodeMaps\Facade\GaodeMapsFacade',
]

Publish configuration file using php artisan vendor:publish --tag=gaodemaps --force or simply copy package configuration file and paste into config/gaodemaps.php, (*9)

Open configuration file config/gaodemaps.php and add your service key, (*10)

    /*
    |----------------------------------
    | Service Keys
    |------------------------------------
    */

    'key'       => 'YOUR GAODE API KEY HERE',

If you like to use different keys for any of the services, you can overwrite master API Key by specifying it in the service array for selected web service., (*11)

Usage

Here is an example of making request to Places Search API:, (*12)

$service = GaodeMaps::load('nearbysearch')
        ->setParam([
            'location'          => '120.392164,36.056936',  // Longitude first in Chinese convention 
            'keywords'          => '้คๅŽ…',
            'radius'            => 5000,
            'page'              => 1,
            'extensions'        => 'all',
            'output'            => 'json'
        ]);
$response = $service->get();
...

Alternatively parameters can be set using setParamByKey() method. For deeply nested array use "dot" notation as per example below., (*13)

$endpoint = GaodeMaps::load('nearbysearch')
        ->setParamByKey('location', '120.392164,36.056936')
        ->setParamByKey('keywords', '้คๅŽ…') //return $this
...

Another example showing request to Batch Request service when requesting multiple places' details:, (*14)

$batch_urls = array();
array_push($batch_urls, (object) array(
    'url' => GaodeMaps::load('placedetails')
        ->setParam(['id' => $place->id)
        ->getBatchUrl()
    )
);

$service = GaodeMaps::load('batchrequest')
        ->setParam([
            'ops'               => $batch_urls
        ]);
$response = $batch_service->get();
...

Available methods


load( $serviceName ) - load web service by name, (*15)

Accepts string as parameter, web service name as specified in configuration file.
Returns reference to it's self., (*16)

GaodeMaps::load('nearbysearch') 
... 


setParamByKey( $key, $value ) - set request parameter using key:value pair, (*17)

Accepts two parameters: * key - body parameter name * value - body parameter value, (*18)

Deeply nested array can use 'dot' notation to assign value.
Returns reference to it's self., (*19)

$service = GaodeMaps::load('nearbysearch')
        ->setParamByKey('location', '120.392164,36.056936')
        ->setParamByKey('keywords', '้คๅŽ…') //return $this
...

setParam( $parameters ) - set all request parameters at once, (*20)

Accepts array of parameters
Returns reference to it's self., (*21)

$service = GaodeMaps::load('nearbysearch')
        ->setParam([
            'location'          => '120.392164,36.056936',  // Longitude first in Chinese convension 
            'keywords'          => '้คๅŽ…',
            'radius'            => 5000,
            'page'              => 1,
            'extensions'        => 'all',
            'output'            => 'json'
        ]); // return $this
...

getBatchUrl() - generate a Url of this service for Batch Request web service, (*22)

Returns Batch Request url of this service., (*23)

$url = GaodeMaps::load('nearbysearch')
    ->setParam([
        'location'          => '120.392164,36.056936',  // Longitude first in Chinese convension 
        'keywords'          => '้คๅŽ…',
        'radius'            => 5000,
        'page'              => 1,
        'extensions'        => 'all',
        'output'            => 'json'
    ])->getBatchUrl();
...

* get() - perform web service request (irrespectively to request type POST or GET ), (*24)

Returns web service response in the format specified by setEndpoint() method, if omitted defaulted to JSON. Use json_decode() to convert JSON string into PHP variable. See Processing Response for more details on parsing returning output., (*25)

$response = GaodeMaps::load('nearbysearch')
        ->setParam([
            'location'          => '120.392164,36.056936',  // Longitude first in Chinese convension 
            'keywords'          => '้คๅŽ…',
            'radius'            => 5000,
            'page'              => 1,
            'extensions'        => 'all',
            'output'            => 'json'
        ])->get();

var_dump(json_decode($response));  // output 
...

/*
{
    "status": "1",
    "count": "274",
    "info": "OK",
    "infocode": "10000",
    "suggestion": {
        "keywords": [],
        "cities": []
    },
    "pois": [
        "0": {
            "id": "B0FFFF4RX1",
            "tag": "็‰›้“็บข่Šฑ็‰›ไธ‰ๅ“,่Œ็ฑปๆ‹ผ็›˜,ๆ–ฐๅฟซ็ŒชไธŠไบ”่Šฑ,็‰›่ˆŒๅŽšๅˆ‡,็Ÿณ้”…ๆ‹Œ้ฅญ,็บข่Šฑไธ‰ๆ‹ผ,็บข่Šฑ็‰›่Šๅฃซ็›–้ฅญ,็ƒค่˜‘่‡,็บข่Šฑ็‰›่‚‰,็Œช้›ช่Šฑ่‚ฉ่ƒ›่‚‰,็‰›่ˆŒ่–„ๅˆ‡,็”Ÿๆ‹Œ็‰›่‚‰,่ฟทไฝ ็ŽฐๅŽ‹ๆœ้ฒœๅ†ท้ข,็‚’ไนŒๅ†ฌ้ข,็‰›่‚ฉ่ƒ›่‚‰,้…ฑ้ฆ™็‰›่…ฟ่Šฏ,ๆตท้ฒœ้ฅผ,็‰›่‚‹่„Š,ๆณก่œ้ฅผ,็ƒค็‰›่‚‰,็‰›ไป”้ชจ,ๆตท้ฒœไนŒๅ†ฌ้ข,็บข่Šฑ็‰›็‰น่‰ฒไธ‰ๆ ท,็ƒคไบ”่Šฑ่‚‰,ๆžๅ“ไธ€ๅฃ็‰›ๆŽ’",
            "name": "ๆ–ฐๅฟซ็‰›้“็บข่Šฑ็‰›้ฆ†(็™พไธฝๅนฟๅœบๅบ—)",
            "type": "้ค้ฅฎๆœๅŠก;ไธญ้คๅŽ…;็‰น่‰ฒ/ๅœฐๆ–น้ฃŽๅ‘ณ้คๅŽ…",
...
*/

MIT License

Collection of Gaode Web Services API for Laravel 5 is released under the MIT License., (*26)

The Versions

01/03 2018

dev-master

9999999-dev

This is a php package for Gaode Web Services API

  Sources   Download

MIT

The Requires

 

by Yan Lin Wang

places api web service gaode maps api gaode web services api china places api laravel places api ้ซ˜ๅพท api

19/12 2017

0.0.0

0.0.0.0

This is a php package for Gaode Web Services API

  Sources   Download

MIT

The Requires

 

by Yan Lin Wang

places api web service gaode maps api gaode web services api china places api laravel places api ้ซ˜ๅพท api