Giter Club home page Giter Club logo

google-maps's Introduction

Collection of Google Maps API Web Services for Laravel

Provides convenient way of setting up and making requests to Maps API from Laravel application. For services documentation, API key and Usage Limits visit Google Maps API Web Services and Maps API for Terms of Service License Restrictions.

Features

Dependency

Notes

Rmoving Place Add, Delete & Radar Search features

Requests to the Places API attempting to use these features will receive an error response

  • Place Add
  • Place Delete
  • Radar Search

Deprication notices for Google Places API Web Service that effects Premium data (Zagat), types parameter, id and reference fields.

  • Nearby Search - types parameter depricated, use parameter type (string)
  • Place Details - the reference is now deprecated in favor of placeid (placeid originally used in this package)
  • Place Add - still uses types parameter as per service documentation
  • Place Autocomplete - still uses types parameter as per service documentation

Installation

Issue following command in console:

composer require alexpechkarev/google-maps

Alternatively edit composer.json by adding following line and run composer update

"require": {
		....,
		"alexpechkarev/google-maps":"^11.0",

	},

Configuration

Register package service provider and facade in 'config/app.php'

'providers' => [
    ...
    GoogleMaps\ServiceProvider\GoogleMapsServiceProvider::class,
]

'aliases' => [
    ...
    'GoogleMaps' => GoogleMaps\Facade\GoogleMapsFacade::class,
]

Publish configuration file using php artisan vendor:publish --tag=googlemaps or simply copy package configuration file and paste into config/googlemaps.php

Open configuration file config/googlemaps.php and add your service key

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

    'key'       => 'ADD YOUR SERVICE 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.

Usage

Here is an example of making request to Geocoding API:

$response = \GoogleMaps::load('geocoding')
		->setParam (['address' =>'santa cruz'])
 		->get();

By default, where appropriate, output parameter set to JSON. Don't forget to decode JSON string into PHP variable. See Processing Response for more details on parsing returning output.

Required parameters can be specified as an array of key:value pairs:

$response = \GoogleMaps::load('geocoding')
		->setParam ([
		    'address'    =>'santa cruz',
         	    'components' => [
                     	'administrative_area'  => 'TX',
                     	'country'              => 'US',
                      ]

                ])
                ->get();

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

$endpoint = \GoogleMaps::load('geocoding')
   ->setParamByKey('address', 'santa cruz')
   ->setParamByKey('components.administrative_area', 'TX') //return $this
    ...

Another example showing request to Places API Place Add service:

$response = \GoogleMaps::load('placeadd')
                ->setParam([
                   'location' => [
                        'lat'  => -33.8669710,
                        'lng'  => 151.1958750
                      ],
                   'accuracy'           => 0,
                   "name"               =>  "Google Shoes!",
                   "address"            => "48 Pirrama Road, Pyrmont, NSW 2009, Australia",
                   "types"              => ["shoe_store"],
                   "website"            => "http://www.google.com.au/",
                   "language"           => "en-AU",
                   "phone_number"       =>  "(02) 9374 4000"
                          ])
                  ->get();

Available methods


load( $serviceName ) - load web service by name

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

\GoogleMaps::load('geocoding')
...

setEndpoint( $endpoint ) - set request output

Accepts string as parameter, json or xml, if omitted defaulted to json. Returns reference to it's self.

$response = \GoogleMaps::load('geocoding')
		->setEndpoint('json')  // return $this
		...

getEndpoint() - get current request output

Returns string.

$endpoint = \GoogleMaps::load('geocoding')
		->setEndpoint('json')
		->getEndpoint();

echo $endpoint; // output 'json'

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

Accepts two parameters:

  • key - body parameter name
  • value - body parameter value

Deeply nested array can use 'dot' notation to assign value. Returns reference to it's self.

$endpoint = \GoogleMaps::load('geocoding')
   ->setParamByKey('address', 'santa cruz')
   ->setParamByKey('components.administrative_area', 'TX') //return $this
    ...

setParam( $parameters) - set all request parameters at once

Accepts array of parameters Returns reference to it's self.

$response = \GoogleMaps::load('geocoding')
                ->setParam([
                   'address'     => 'santa cruz',
                   'components'  => [
                        'administrative_area'   => 'TX',
                        'country'               => 'US',
                         ]
                     ]) // return $this
...

  • get() - perform web service request (irrespectively to request type POST or GET )
  • get( $key ) - accepts string response body key, use 'dot' notation for deeply nested array

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.

$response = \GoogleMaps::load('geocoding')
                ->setParamByKey('address', 'santa cruz')
                ->setParamByKey('components.administrative_area', 'TX')
                 ->get();

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

/*
{\n
   "results" : [\n
      {\n
         "address_components" : [\n
            {\n
               "long_name" : "277",\n
               "short_name" : "277",\n
               "types" : [ "street_number" ]\n
            },\n
            ...
*/

Example with $key parameter

$response = \GoogleMaps::load('geocoding')
                ->setParamByKey('latlng', '40.714224,-73.961452')
                 ->get('results.formatted_address');

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

/*
array:1 [▼
  "results" => array:9 [▼
    0 => array:1 [▼
      "formatted_address" => "277 Bedford Ave, Brooklyn, NY 11211, USA"
    ]
    1 => array:1 [▼
      "formatted_address" => "Grand St/Bedford Av, Brooklyn, NY 11211, USA"
    ]
            ...
*/

isLocationOnEdge( $lat, $lng, $tolrance = 0.1 ) - To determine whether a point falls on or near a polyline, or on or near the edge of a polygon, pass the point, the polyline/polygon, and optionally a tolerance value in degrees.

This method only available with Google Maps Directions API.

Accepted parameter:

  • $lat - double latitude
  • $lng - double longitude
  • $tolrance - double
$response = \GoogleMaps::load('directions')
            ->setParam([
                'origin'          => 'place_id:ChIJ685WIFYViEgRHlHvBbiD5nE',
                'destination'     => 'place_id:ChIJA01I-8YVhkgRGJb0fW4UX7Y',
            ])
           ->isLocationOnEdge(55.86483,-4.25161);

    dd( $response  );  // true

containsLocation( $lat, $lng ) -To find whether a given point falls within a polygon.

This method only available with Google Maps Directions API.

Accepted parameter:

  • $lat - double latitude
  • $lng - double longitude
$response = \GoogleMaps::load('directions')
            ->setParam([
                'origin'          => 'place_id:ChIJ685WIFYViEgRHlHvBbiD5nE',
                'destination'     => 'place_id:ChIJA01I-8YVhkgRGJb0fW4UX7Y',
            ])
           ->containsLocation(55.86483,-4.25161);

    dd( $response  );  // true

Support

Please open an issue on GitHub

License

Collection of Google Maps API Web Services for Laravel is released under the MIT License. See the bundled LICENSE file for details.

google-maps's People

Contributors

alexpechkarev avatar brianrlewis avatar cyrillkalita avatar danswiser avatar fa2mm avatar facundofarias avatar gart77 avatar laravel-shift avatar lyimmi avatar makhnovskiy avatar markwalet avatar neoteknic avatar nmfzone avatar parkourben99 avatar repat avatar sdekkers avatar syrok avatar vesper8 avatar xeader 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  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  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  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

google-maps's Issues

header is not json

$response->setEndpoint('json')->get();

return json with html header

and I have to use :

return response($response)->header('Content-Type', 'application/json');

to set header

Directions string

Hi.

why can't i insert a string in destinations ($localdest) in this code?

  $d = \GoogleMaps::load('distancematrix')
          ->setParam([
          'origins'       => [$localorig],
          'destinations'  => [$localdest],
      ])
      ->getResponseByKey('distance');

Anyone can help?

alternatives=true to get other itinary

Hello i would like to get the shortest way from a point A to a point B and not the fastest. So i looked around on the forums and i found alternatives=true param who gives you different alternatives.

How could i check the differents way ? actually i have this in my controller to calculate the distance * 2. I simply whould like to check if there is a shortest way and if it is i get the shortest way. hope you could help me. thanks a lot in advance

`$origin = $licencie->lb_adresse .' '. $licencie->lb_ville_naissance .' '. $licencie->cd_dept_naissance;
$destination = $rencontre->stade->adresse_stade .' '. $rencontre->stade->ville_stade .' '. $rencontre->stade->cd_post_stade;

    $response = \GoogleMaps::load('directions')
        ->setParam([
            'origin'          => $origin,
            'destination'     => $destination,
            'mode' => 'driving' ,
            //'alternatives' => true,
            'language' => 'fr',

        ])->get();

    $parsed_json = (json_decode($response));

    $result = $parsed_json->{'routes'}[0]->{'legs'}[0]->{'distance'}->{'text'};

    $a = $result;
    $b = str_replace(" km",'',$a);
    $distance = str_replace(",",'.',$b);

    //distance * 2 
    $distance = $distance * 2 ;`

Not returning any route in directions

Hi there, how r u?

I'm facing a problem, when I make a few requests, for some of them i get no route. when i go to google maps and input same data, i get routes from there. can give any idea what is going on?

thank you

Elevetion service with a long list a value is rejected by Google

This request works (replace MYKEY with your key) :
https://maps.googleapis.com/maps/api/elevation/json?key=<MYKEY>&locations=45.523720,-73.538790|45.524540,-73.538650|45.525100,-73.538500|45.525840,-73.538200|45.526270,-73.537990|45.526920,-73.537570|45.527280,-73.537310|45.527740,-73.536910|45.528110,-73.536650|45.529090,-73.535880|45.529040,-73.535120|45.528870,-73.532620|45.529050,-73.535320|45.529080,-73.535780|45.527880,-73.536690|45.527810,-73.536730|45.527720,-73.536760|45.527630,-73.536720|45.527310,-73.536590|45.526910,-73.536390|45.526880,-73.536330|45.527060,-73.535700|45.527060,-73.535580|45.526960,-73.534920|45.526930,-73.534840|45.526840,-73.534710|45.526690,-73.534610|45.526620,-73.534470|45.526540,-73.534240|45.526470,-73.534200|45.525940,-73.534040|45.525890,-73.534030|45.525850,-73.533860|45.525800,-73.533690|45.525520,-73.533220|45.525000,-73.532430|45.524840,-73.532130|45.524720,-73.532010|45.524660,-73.531970|45.524540,-73.531930|45.524410,-73.531900|45.524060,-73.531880|45.523010,-73.531880|45.522120,-73.531790|45.521760,-73.531770|45.519710,-73.531480|45.519300,-73.531390|45.519220,-73.531360|45.518860,-73.531150|45.518770,-73.531150|45.518470,-73.531030|45.518210,-73.530900|45.518050,-73.530850|45.517740,-73.530780|45.517070,-73.530650|45.515930,-73.530420|45.515610,-73.530350|45.515340,-73.530260|45.515080,-73.530170|45.514860,-73.530150|45.514530,-73.530170|45.514230,-73.530260|45.514090,-73.530320|45.513680,-73.530570|45.513400,-73.530690|45.512990,-73.530790|45.512960,-73.530800|45.512990,-73.530790|45.512990,-73.530570|45.512970,-73.527880|45.512150,-73.527880|45.511710,-73.527930|45.511320,-73.528020|45.510890,-73.528130|45.510350,-73.528340|45.509720,-73.528620|45.509510,-73.528640|45.509260,-73.528630|45.509010,-73.528570|45.508880,-73.528490|45.508810,-73.528440|45.508790,-73.528420|45.508910,-73.528270|45.509000,-73.528180|45.509230,-73.528060|45.509610,-73.527900|45.510240,-73.527660|45.511060,-73.527430|45.511630,-73.527300|45.512040,-73.527270|45.512300,-73.527270|45.512530,-73.527280|45.512750,-73.527320|45.513640,-73.527570|45.514100,-73.527700|45.514180,-73.527690|45.514240,-73.527640|45.514260,-73.527610|45.514290,-73.527550|45.514300,-73.527480|45.514280,-73.527390|45.514240,-73.527290|45.514120,-73.527220|45.513730,-73.527150|45.513450,-73.527130|45.513320,-73.527100|45.513120,-73.527010|45.512410,-73.526530|45.510260,-73.525350|45.510010,-73.525240|45.507920,-73.524610|45.503920,-73.523440|45.503340,-73.523240|45.503330,-73.523240|45.503170,-73.523240|45.502740,-73.523330|45.502630,-73.523320|45.499710,-73.522440|45.499390,-73.522390|45.499260,-73.522380|45.499110,-73.522390|45.498950,-73.522370|45.497700,-73.521990|45.497480,-73.521950|45.497280,-73.521940|45.497160,-73.522020|45.497070,-73.522170|45.497040,-73.522430|45.497070,-73.522760|45.497150,-73.523200|45.497350,-73.523970|45.497450,-73.524220|45.497670,-73.524640|45.498750,-73.526350|45.499130,-73.526840|45.499480,-73.527220|45.500010,-73.527730|45.500440,-73.528090|45.501280,-73.528710|45.501640,-73.528960|45.502180,-73.529240|45.502720,-73.529470|45.502890,-73.529540|45.503720,-73.529780|45.503940,-73.529820|45.504830,-73.529910|45.505530,-73.529940|45.505790,-73.529920|45.506590,-73.529820|45.507130,-73.529680|45.507790,-73.529440|45.508560,-73.529130|45.508497,-73.528748|45.508151,-73.528748|45.507956,-73.528962|45.508016,-73.529842|45.508250,-73.531550|45.508340,-73.532220|45.508370,-73.532550|45.508390,-73.532680|45.508380,-73.532810|45.508370,-73.532930|45.508300,-73.533130|45.508240,-73.533190|45.507880,-73.534260|45.507500,-73.535290|45.507280,-73.535900|45.504900,-73.542340|45.504900,-73.542490|45.504740,-73.542920|45.504550,-73.543390|45.504390,-73.543660|45.504210,-73.543850|45.504020,-73.543970|45.503890,-73.544020|45.503740,-73.544040|45.503580,-73.544060|45.503510,-73.544060|45.503410,-73.544010|45.502160,-73.544140|45.500040,-73.544380|45.497820,-73.544650
fails.
It looks like Google does not accept more than 2048 characters as parameters.
It would by nice if your library could break the request into many requests and returns the concatenated request so the this limitation would by hidden from the caller.
Or any other way to bybass the limitation properly?
Thanks

Problem submitting an array of lon/lat with elevation service

In joinParam method of Parameters.php

return !is_null( $allParam )
                ? implode($glue, str_replace(['%252C'],[','],$allParam) )
                :''; 

should be replaced by

return !is_null( $allParam )
                ? implode($glue, str_replace(['%7C'],['|'],str_replace(['%252C'],[','],$allParam)) )
                :'';

in order to managed a list of lat/lon when calling an "elevation" Google service.
This is cause be the encoding replacing "|" by the encoded value (%7C). There might be also a different way to do that.

Decode Polyline point returned by Google Directions API

Hi
I just installed your library and it looks pretty cool. Just wondering if there is any method to decode the polyline point returned in Directions response. Here is Directions API response:

{
   "geocoded_waypoints" : [
      {
         "geocoder_status" : "OK",
         "place_id" : "ChIJlfTBINcEGTkR_Wu1RAUpDYI",
         "types" : [ "street_address" ]
      },
      {
         "geocoder_status" : "OK",
         "place_id" : "ChIJlfTBINcEGTkR_Wu1RAUpDYI",
         "types" : [ "street_address" ]
      }
   ],
   "routes" : [
      {
         "bounds" : {
            "northeast" : {
               "lat" : 31.5562273,
               "lng" : 74.3571711
            },
            "southwest" : {
               "lat" : 31.55462439999999,
               "lng" : 74.3546016
            }
         },
         "copyrights" : "Map data ©2015 Google",
         "legs" : [
            {
               "distance" : {
                  "text" : "0.3 km",
                  "value" : 302
               },
               "duration" : {
                  "text" : "1 min",
                  "value" : 45
               },
               "end_address" : "132 Allama Iqbal Road, Lahore, Pakistan",
               "end_location" : {
                  "lat" : 31.5562273,
                  "lng" : 74.3546016
               },
               "start_address" : "132 Allama Iqbal Road, Lahore, Pakistan",
               "start_location" : {
                  "lat" : 31.55462439999999,
                  "lng" : 74.3571711
               },
               "steps" : [
                  {
                     "distance" : {
                        "text" : "0.3 km",
                        "value" : 302
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 45
                     },
                     "end_location" : {
                        "lat" : 31.5562273,
                        "lng" : 74.3546016
                     },
                     "html_instructions" : "Head \u003cb\u003enorthwest\u003c/b\u003e on \u003cb\u003eAllama Iqbal Rd\u003c/b\u003e",
                     "polyline" : {
                        "points" : "k_r_Ei{ydM[r@e@bAOZWh@Ub@]p@c@`AU^e@p@cAxA"
                     },
                     "start_location" : {
                        "lat" : 31.55462439999999,
                        "lng" : 74.3571711
                     },
                     "travel_mode" : "DRIVING"
                  }
               ],
               "via_waypoint" : []
            }
         ],
         "overview_polyline" : {
            "points" : "k_r_Ei{ydMiB|Ds@tAy@`BiBjC" // this is the encoded polyline point to decode
         },
         "summary" : "Allama Iqbal Rd",
         "warnings" : [],
         "waypoint_order" : []
      }
   ],
   "status" : "OK"
}

I already decoded the point in JS, I need your help to do same using this library.

Thanks

Directions with LatLng not working

Hi,

if I try:

\GoogleMaps::load('directions') ->setParam([ 'origin' => "Barcelona, ES", 'destination' => "Madrid, ES", ]) ->get();

works properly.

When I try:

\GoogleMaps::load('directions') ->setParam([ 'origin' => ['lat' => 41.3850639, 'lng' => 2.1734035], 'destination' => ['lat' => 40.4167754, 'lng' => -3.7037902], ]) ->get();

the response is:

{"geocoded_waypoints":[{"geocoder_status":"ZERO_RESULTS"},{"geocoder_status":"ZERO_RESULTS"}],"routes":[],"status":"NOT_FOUND"}

Someone has been able to use directions API with lat/lng parameters?

Thanks.

Google map is not seeing as a Map but as code/coordinate

I'm trying to display google map on the view. But I can't displaying it as a map.
I think I am missing something but couldn't sure what.

here it is a example of my controller and view.

public function map()
    {
        $response = \GoogleMaps::load('geocoding')
            ->setParam(['address' => 'tokyo'])
            ->get();
        return view('welcome', compact('response'));
    }
<div style="width: 500px; height: 500px;">

   {{ $response }}

</div>

what i am missing here: it returns on page like this.

{ "results" : [ { "address_components" : [ { "long_name" : "Tokyo", "short_name" : "Tokyo", "types" : [ "administrative_area_level_1", "locality", "political" ] }, { "long_name" : "Japan", "short_name" : "JP", "types" : [ "country", "political" ] } ], "formatted_address" : "Tokyo, Japan", "geometry" : { "bounds" : { "northeast" : { "lat" : 35.8986468, "lng" : 153.9876115 }, "southwest" : { "lat" : 24.2242626, "lng" : 138.942758 } }, "location" : { "lat" : 35.6894875, "lng" : 139.6917064 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 35.817813, "lng" : 139.910202 }, "southwest" : { "lat" : 35.528873, "lng" : 139.510574 } } }, "place_id" : "ChIJ51cu8IcbXWARiRtXIothAS4", "types" : [ "administrative_area_level_1", "locality", "political" ] } ], "status" : "OK" }

Get response

Hi, how can return multiples paramters? i need return name, photo, address, etc.
i tried with this
get('response.name.photo')
get('response.['name.,photo']')

but the response is all parameters.

Loading More than one service name at the same time

Good day, so I am working on a project for a real estate agency, and to provide more information for users seeking to find an apartment I would like to add a feature were nearby locations like schools, restaurants, night clubs and so on can be shown and I have been finding it very difficult.

So here's the question, can I load more than one serviceName, and if I can, how do I get responses for each service. See example

$response = \GoogleMaps::load('geocoding', 'nearbysearch', placeadd)
                                ->setParamByKey('address', $property->address)
                                ->setParamByKey('latlng', [how do I reference the lat and lng here])
                                ->setParamByKey('radius', 1500)
                                ->get('results.geometry.location');

Note that the property address comes directly from the database dynamically. I really hope I made sense. I would need help.

create polygon and check point in polygon

in my food delivery system i need to divide city to multiple zone and set price of each zone for delivery system

can I use this package to create polygon and check user location is in any polygons?

Refrence in curl

Can I pass CURLOPT_REFERER to the request?
Is there any parameter key?

array_merge(): Argument #1 is not an array

I would like to report an issue that I am facing.
I installed this package with laravel 5.3.
Whenever I am calling placedetails method like below
$location = \GoogleMaps::load('place_details')
->setParam(['placeid' => 'ChIJN1t_tDeuEmsRUsoyG83frY4'])->get();

I am getting following exception.

in WebService.php line 141
at HandleExceptions->handleError('2', 'array_merge(): Argument #1 is not an array', '/Users/avinashmishra/lab/sd/laravel-backend/vendor/alexpechkarev/google-maps/src/WebService.php', '141', array('param' => array('placeid' => 'ChIJN1t_tDeuEmsRUsoyG83frY4'), 'this' => object(GoogleMaps)))
at array_merge(null, array('placeid' => 'ChIJN1t_tDeuEmsRUsoyG83frY4')) in WebService.php line 141
at WebService->setParam(array('placeid' => 'ChIJN1t_tDeuEmsRUsoyG83frY4')) in ApisController.php line 23
at ApisController->location(object(Request))
at call_user_func_array(array(object(ApisController), 'location'), array(object(Request))) in Controller.php line 55
at Controller->callAction('location', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(ApisController), 'location') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 642
at Router->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in ThrottleRequests.php line 49
at ThrottleRequests->handle(object(Request), object(Closure), '60', '1') in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 644
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53

Extra space in Facade config

-- 'GoogleMaps' => ' GoogleMaps\Facade\GoogleMapsFacade',

There's an extra space in the value of the facade config. Took me 20 minutes to figure out why it was throwing the error: Class ' GoogleMaps\Facade\GoogleMapsFacade' not found

Always get error offset

Have no idea what this is "unserialize(): Error at offset 0 of 40 bytes". What caused the problem of this error?

How to show map in laravel with https://github.com/alexpechkarev/google-maps ?

I am workin on laravel project in which i have to integrate google maps. I am using this package https://github.com/alexpechkarev/google-maps for google maps . I install this package and get api key from https://console.developers.google.com/apis/credentials . then I just follow the usage of this package for example i write the code in my controller

$response = \GoogleMaps::load('geocoding')
->setParam (['address' =>'santa cruz'])
->get();
It giving me data in json encode formate but i dont know what i do next . How can i display maps in view blade.php . can someone please give me proper example of this package via code i will be thankfull for that thanks in advanced

Pass an array of waypoints to directions

hello,

i want to pass an array of waypoints to the directions service but it is not working.
even converting the array to a string does not work.

when i use: 'waypoints' => [$array]', it is not working, even when array is a string like: 'Vancouver BC', 'Seattle'.

But when i type this, and not use a variable, it does work.

Can you help me?

Multiple Pins

Could you use this to pin multiple locations on a single map for like a overview of locations?

FatalErrorException in compiled.php line 5301:

Hi,

I'm currently working on a project that involves google maps turn by turn directions.

I encounter this error, what could be the cause of this?

Call to undefined method Illuminate\Support\Facades\GoogleMapsFacade::load()

I placed the GoogleMapsFacade.php to Illuminate\Support\Facades\ directory.

Thanks in advance.

json_decode fails to parse the response

I have been trying to do the following
public function index()
{
$d = \GoogleMaps::load('directions')->setEndpoint('json')
->setParamByKey('origin', 'Bengaluru')
->setParamByKey('destination', 'Kolkata')->get();

             //   echo $d;

$json_a= json_decode($d,true);
echo $json_a->geocoded_waypoints[0]->geocoder_status;
But I am not getting any values .Can anyone please help me out

Update README

Please update README.md file
Change
'providers' => [
...
'GoogleMaps\ServiceProvider\GoogleMapsServiceProvider',
]

'aliases' => [
...
'GoogleMaps' => 'GoogleMaps\Facade\GoogleMapsFacade',
]
To
'providers' => [
...
GoogleMaps\ServiceProvider\GoogleMapsServiceProvider::class,

'aliases' => [
...
GoogleMaps' => GoogleMaps\Facade\GoogleMapsFacade::class,
]
This is very misleading for people who would just copy the code and paste in their file. Awesome project.

curl_setopt()

Hi Alex.

I try to deploy my laravel project. But I got this error

ErrorException in WebService.php line 372:
curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set

It works perfectly at localhost. If you please help me with this issue I'll be really grateful.. Thanks..

duration_in_traffic Response / Directions API

Hi Alex,

is it possible to make a signed request to google (directions api) in order to get the duration_in_traffic response? I'm building a dashboard for my family to show how long everybody needs to get to work, school etc.

Best regards,
Rene

Distance Matrix

How do you use the distancematrix from google?
Dont seem to figure out how to pass the origins and destinations..

[Help] Use Case

Can i use this to add a map to my view which shows a location based on postcode.

If so can you give me an example on how i can do this. (I have the package configured and setup already)

thank you in advance.

webservice:268 error

local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Can't use function return value in write context' in /var/www/'user'l/httpdocs/laravel/vendor/alexpechkarev/google-maps/src/WebService.php:268

Hi i just started using laravel as framework and am almost done with my project with it. I have a problem with the google-maps. Everytime i try this code

$response = \GoogleMaps::load('geocoding')->setParam (['address' =>'santa cruz'])->get();
I get the error thats written above.
If you can please help me with this issue ill be really grateful.

Optimize Waypoints in directions API not working properly

Setting the parameter optimizeWaypoints to true doesn't change the response.

In the example from maps api documentation destinations are set this way:
(...)waypoints=optimize:true|Barossa+Valley,SA|Clare,SA|Connawarra,SA|McLaren+Vale,SA

The curl request in this library adds the optimizeWaypoints=true to the end of the URL which doesn't return the array optimized_waypoints order correctly.

Proximity radio

Hi, I'm working on an app that should filter the nearby items within a radius of 20km. I have stored in db lat and lng, how could I implement it in your plugin? I searched but I do not understand and I need your help.

Thank you for your awesome contributions!

How to use)

Hello.
Can i use this class Wihout framework Laravel?

Incompatibility of params with non ASCII characters

Hello,

I'm trying to do a search with geocoding library for the locality "Póvoa de Santa Iria, Portugal".
What is happening is that params are being encoded 2 times, and because of portuguese characters, url is distorted and no results are found.

Here is the difference:
Url by hand:
https://maps.googleapis.com/maps/api/geocode/json?key=[key]&components=locality:Póvoa de Santa Iria, Portugal

With the package it becomes
https://maps.googleapis.com/maps/api/geocode/json?key=[key]&components=locality%3AP%25C3%25B3voa%2Bde%2BSanta%2BIria,%2BPortugal

Php 7.2 incompatibility

Have this exception running php 7.2 laravel 5.5

ErrorException count(): Parameter must be an array or an object that implements Countable

/vendor/alexpechkarev/google-maps/src/WebService.php:305

// Validate Endpoint
if(!array_key_exists('endpoint', config('googlemaps') )
        || !count(config('googlemaps.endpoint') < 1)){
    throw new \ErrorException('End point must not be empty.');
}

composer dump-autoload -o

Hello,

I experienced this issue running laravel 5.3 project

PHP Fatal error: Class 'GoogleMaps\ServiceProvider\GoogleMapsServiceProvider' not found

I add these lines to config/app.php

--> Providers

GoogleMaps\ServiceProvider\GoogleMapsServiceProvider::class,

--> Alias

'GoogleMaps' => GoogleMaps\Facade\GoogleMapsFacade::class,

Composer update is running fine and install your library with no issue.

I try
composer dump-autoload -o
No luck with this

Have an idea ?
Thanks a lot

Set API key dynamically

Hello,

I need to obtain the API key dynamically from a database, depending on the application instance.
It cannot be obtained statically from the config file.
Are there any way to set it per API call, or dynamically set it on the config options? Thanks.

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.