Comments (8)
That API key is worse one here. I also trying to solve how the heck merge that into my version and make appropriate tests and it's PITA. That inconsistences between APIs on G's side is awful. It might came to v3 - just due changes in internal APIs.
from google-maps-services-php.
After through look onto example I do not know how the merged service can work, because API key is not part of GET part and instead it is sent through header as an extra param.
from google-maps-services-php.
Yes, what I merged in is working
But you are right, the headers key for it seems not needed, query string part seems to suffice.
from google-maps-services-php.
Example in my CakePHP app:
$gmaps = new Client(['key' => Configure::readOrFail('google.apikey.routes')]);
$x = [
'location' =>
[
'latLng' =>
[
'latitude' => 37.419734,
'longitude' => -122.0827784,
],
],
'sideOfRoad' => true,
];
$y =[
'location' =>
[
'latLng' =>
[
'latitude' => 37.41767,
'longitude' => -122.079595,
],
],
];
$params = [
'intermediates' =>
[
[
'location' =>
[
'latLng' =>
[
'latitude' => 37.412734,
'longitude' => -122.0107784,
],
],
],
],
'travelMode' => 'DRIVE',
'routingPreference' => 'TRAFFIC_AWARE',
'computeAlternativeRoutes' => false,
'routeModifiers' =>
[
'avoidTolls' => false,
'avoidHighways' => false,
'avoidFerries' => false,
],
'languageCode' => 'de-CH',
'units' => 'METRIC',
'headers' => [
'X-Goog-FieldMask' => 'routes.duration,routes.distanceMeters',
],
];
$geocodeResult = $gmaps->route($x, $y, $params);
from google-maps-services-php.
With #12 merged we can now close this.
from google-maps-services-php.
Okay. Although by the Google's own example of HTTP under combined with your settings:
curl -X POST -d '{
"origin":{
"location":{
"latLng":{
"latitude": 37.419734,
"longitude": -122.0827784
}
}
},
"destination":{
"location":{
"latLng":{
"latitude": 37.417670,
"longitude": -122.079595
}
}
},
"travelMode": "DRIVE",
"routingPreference": "TRAFFIC_AWARE",
"computeAlternativeRoutes": false,
"routeModifiers": {
"avoidTolls": false,
"avoidHighways": false,
"avoidFerries": false
},
"languageCode": "de-CH",
"units": "METRIC"
}' \
-H 'Content-Type: application/json' \
-H 'X-Goog-Api-Key: **YOUR_API_KEY**' \
-H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.polyline.encodedPolyline' \
'https://routes.googleapis.com/directions/v2:computeRoutes'
then the possibility of usage the API key via GET param is undocumented one.
from google-maps-services-php.
We can definitly change the code to favor header :)
from google-maps-services-php.
from google-maps-services-php.
Related Issues (7)
- Fix the readme composer instructions HOT 2
- Release required HOT 4
- Patch release HOT 1
- Support Guzzle v7 HOT 1
- Add PHPDocs for various methods on Client class HOT 4
- Support PSR HTTP client HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-maps-services-php.