I'm using google elevation service
I want to fetch data for my path, which consists of about 1k points.
I know that I cannot sent them all in query divided by |
separator, because I would exceed request size limit, so I'm encoding those points as it is mentioned in docs by Encoded Polyline Algorithm and send them like:
https://maps.googleapis.com/maps/api/elevation/json?key=KEY&path=cgg%7EE%7C%7B%7EpUfcaAwe%7CG&samples=3
Points: 36.578581,-118.291994|36.23998,-116.83171
Points encoded: cgg~E|{~pUfcaAwe|G
Points encoded + urlencoded: cgg%7EE%7C%7B%7EpUfcaAwe%7CG
But I'm getting the following error message:
Invalid request. Invalid 'path' parameter.
.
When I ask google with non encoded query (path separated by pipe separator) I receive proper data.
Do you have some hints what I am doing wrong in here?
The
path
parameter expects your encoded points to be prefixed withenc:
This is not super clear from the documentation, I must admit.
With your encoded points
cgg~E|{~pUfcaAwe|G
the path parameter would become:path=enc:cgg~E|{~pUfcaAwe|G
Proof of concept:
https://maps.googleapis.com/maps/api/elevation/json?key=YOUR_API_KEY&path=enc:cgg~E|{~pUfcaAwe|G&samples=3
You must replace
YOUR_API_KEY
with your own key.This returns the following: