Google Maps Static API returns strange image

I have a page with static map URIs in the form http: //maps.google.com/maps/api/staticmap? Size = 600x240 & markers = icon: http: //100procentjan.nl/tweakers/punaise.png | shadow: false | 52.369010925293,4.8560848236084 & sensor = false & zoom = 15 & center = 52.369010925293,4.8560848236084 .

When I visit this page from any browser, it displays just fine, but not when I use it through the Blackberry, which is connected through our BES (but the same wireless network!). Then the following image appears:

Argh

Does anyone know what this image means?

+4
source share
4 answers

This is a special BB issue with the Google Static Maps API. The API speed limit is normal, but most often it appears when using BB devices.

They seem to be using an IP pool and are turning them on devices. Theoretically, this should be a very intermittent issue. If you wait a few days, he must leave.

In other words, collectively, your IP hit the Static Maps API more than 1000 times in 24 hours. This also happens if you click on the API too often for a short amount of time.

My solution was to write a simple PHP script that requested the map image from Google once, saved it as a file, and simply served it, rather than hitting the map API every time.

Here is the code:

<?php header('Content-Type: image/jpeg'); $latlng = (isset($_GET['c']))? $_GET['c'] : NULL ; $zoom = (isset($_GET['z']))? $_GET['z'] : 9 ; $file = "cache/p_$p-z_$zoom.jpg"; if(!file_exists($file)) { $parts = array( 'center' => $latlng, 'zoom' => $zoom, 'size' => '320x240', 'maptype' => 'terrain', 'sensor' => 'false', 'format' => 'jpeg' ); file_put_contents( $file, file_get_contents("http://maps.googleapis.com/maps/api/staticmap?".implode('&', $parts)) ); } echo file_get_contents($file); 
+3
source

You have exceeded the usage limit for a specific IP address

"Using the Google Static Maps API is subject to a request limit of 1000 unique (different) image requests per viewer per day"

+5
source

I had the same problem on different wireless media. I believe that this was due to the fact that many users encountered traffic through the same external IP address used by the wireless medium. Google sees them as the source of a single request.

To fix the error, add the Google API key at the end of your request for a static map. Example:

http://maps.googleapis.com/maps/api/staticmap?center=<lat>,<lng>&zoom=17&markers=color:0059A9%7C<lat>,<lng>&size=576x174&sensor=false&key=YOUR_SUPER_LONG_GOOGLE_API_KEY_GOES_HERE

+3
source

I get it too, always, on Blackberry. Donโ€™t think about its usage restrictions because I just woke up and my sharing is 1. Unless its some common IP problem is related to Blackberry.

0
source

Source: https://habr.com/ru/post/1347056/


All Articles