This question already has an answer here:
Draw Google static map image
(1 answer)
Closed 1 year ago.
I tried to send a GET request to
https://maps.googleapis.com/maps/api/staticmap?key=***¢er=443.665751,-79.403373&zoom=12&size=800x600&path=color:0xFF0000AA|weight:1|fillcolor:0xFFB6C1BB|enc:...
which the entire URL size is 272532 bytes. But when I send this request, I get Error 413 (Request Entity Too Large) error with this message:
Your client issued a request that was too large.
Is there any way to send large requests (when the path parameter is very long) to Google Maps Static API?
You can use Encoded Polyline as path parameter in URL request. You can encode polyline via encode() method of PolyUtil class of Maps SDK Utility Library. Also you can reduce number of points in path via simplify() method of PolyUtil class (it implements Ramer–Douglas–Peucker algorithm). So "maximum compression" for path is:
reduce number of points in path using simplify();
reduce length of path parameter of URL request using encode().
Also, you can create several requests with path parts and "merge" response images (as bitmaps) to create full path (e.g. this way).
Related
I have already a code to retrieve the objects in the bucket using oci-java-sdk and this is working as expected. I would like to retrieve the URL of the file which was uploaded to the bucket in object storage and when I use this URL, this should redirect to the actual location without asking any credentials.
I saw preauthenticated requests but again i need to create one more request. I dont want to send one more request and want to get URL in the existing GetObjectResponse.
Any suggestions>
Thanks,
js
The URL of an object is not returned from the API but can be built using information you know (See Update Below!). The pattern is:
https://{api_endpoint}/n/{namespace_name}/b/{bucket_name}/o/{object_name}
Accessing that URL will (generally, see below) require authentication. Our authentication mechanism is described at:
https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/signingrequests.htm
Authentication is NOT required if you configure the bucket as a Public Bucket.
https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/managingbuckets.htm?TocPath=Services%7CObject%20Storage%7C_____2#publicbuckets
As you mentioned, Pre-authenticated Requests (PARs) are an option. They are generally used in this situation, and they work well.
https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/usingpreauthenticatedrequests.htm
Strictly speaking, it is also possible to use our Amazon S3 Compatible API...
https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/s3compatibleapi.htm
...and S3's presigned URLs to generate (without involving the API) a URL that will work without additional authentication.
https://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURL.html
Update: A teammate pointed out that the OCI SDK for Java now includes a getEndpoint method that can be used to get the hostname needed when querying the Object Storage API. https://docs.cloud.oracle.com/en-us/iaas/tools/java/1.25.3/com/oracle/bmc/objectstorage/ObjectStorage.html#getEndpoint--
i'm trying to maintain a project which is trying to post images (yes multiple) from mobile devices to a dot-net web api.
The default content between api and mobile devices is application/json.
public async Task<HttpResponseMessage> PostExpertiseForm(List<string> images){}
This is the actual method for posting and in this method they are trying to write base64 strings (images) to files.
But the problem is when i tried to call this api, for the first time web api binds images with my base64 strings, but all next requests (same request with the first one) are binds to null.
I did some google search and tought about it was a request size problem and i added this lines to Web.config :
<httpRuntime targetFramework="4.6" maxRequestLength="2147483647" />
<requestLimits maxAllowedContentLength="2147483648" />
<jsonSerialization maxJsonLength="2147483644">
Didnt work.
What is the real problem here? Why my first request worked?
Thanks for your advice!
The problem was not about json size. There was a mechanism for logging every response and request, in log request method i saw this line var request=await Request.ReadAsStringAsync();
After little searching about parameterless post methods in web api i found that question why-is-the-body-of-web-api-request-read-once
And i realised that i was try to read the request body twice and caused dead lock.
I changed the logic of logging. The problem has gone.
Charles proxy question.
I need to model a response from an API call using map local. I've done this before, but in this case the API is both returning an image, as well as JSON.
Is it as simple as creating two map local functions for the same call, one returning the required image, the other the required json?
If not, what's the best way of doing this, if it's possible at all that is?
I am using the google-drive-sdk with our company-made device. We upload pictures made by our device to google drive. After that I try to list the files with a GET request to https://www.googleapis.com/drive/v2/files to get thumbnailLink and webContentLink. Everything is working fine except that when I switch to v3 I don't get the response I should. The documentation says I should get a metadata response like https://developers.google.com/drive/v3/reference/files
but I only get: id, kind, name and mimeType. What am I doing wrong?
As stated in Migrate to Google Drive API v3 documentation, there are changes on how fields were returned.
Full resources are no longer returned by default. You need to use the fields query parameter to request specific fields to be returned. If left unspecified only a subset of commonly used fields are returned.
You can see examples on Github. This SO question might also help.
In v3 they made all the queries parametric. So you can query passing some parameter like
var request = gapi.client.drive.files.list({
'pageSize': 10,
'fields': 'files,kind,nextPageToken'
});
This block of code will return you all the information of every file just like v2.
If you are sending a get request then for fetching all the information you can try GET https://www.googleapis.com/drive/v3/files?fields=files%2Ckind%2CnextPageToken&key={YOUR_API_KEY}
Suppose you need ownsers and permissions only then set
var request = gapi.client.drive.files.list({
'pageSize': 10,
'fields':'files(owners,permissions),kind,nextPageToken'
});
For GET request use GET https://www.googleapis.com/drive/v3/files?fields=files(owners%2Cpermissions)%2Ckind%2CnextPageToken&key={YOUR_API_KEY}
for reference you can use Google Developers Documentation for fetching File list
I developed an app that sends GPS points to a server and the server convert those GPS points into a path, which is shown in a map.
Now the server makes a call to Google Maps Directions service and gets a response. From that response I use the value overview_polyline, which based on the documentation:
Contains an object holding an array of encoded points that represent
an approximate path of the resulting directions.
The problem is that sometimes the line I get is really weird. Sometimes it gives me a path where there's no street at all.
Here are some screenshots to describe my problem. The yellow marker is the start point (A), and the blue marker is the end point (B).
So I asked Google to give a route from A to B, with driver mode, so it shows the actually path.
And this is the result:
This is the API call I use. My question is: Any idea why would it return that path?
http://www.geocodezip.com/v3_example_geo2.asp?addr1=53%20Imperial%20Avenue,%20Westport,%20CT%2006880,%20USA&addr2=2%20Harborview%20Road,%20Westport,%20CT%2006880,%20USA&geocode=1&geocode=2&type=m
Looks to me like the encoded polyline is not being rendered correctly. How is your code handling that?
example using the geometry library decodePath function
Looks to me like Google broke their polyline encoding.
If I paste it into here (which admittedly doesn't expect polylines, it expects polyons)
I need to escape the "`", change:
{pazFraw~L|#|#f#^`#N\\?XIx#a#n#[
to:
{pazFraw~L|#|#f#^\`#N\\?XIx#a#n#[
to make it have a more reasonable shape.