Jan Jongboom
Jan Jongboom

Reputation: 27342

Google Maps Static API returns weird image

I have a page that has a static maps URI in the form of 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 shows up just fine, but not when I use it through a Blackberry that is connected through our BES (but same wireless network!). Then this image shows up:

Argh

Does anyone know what this image means?

Upvotes: 4

Views: 6737

Answers (4)

JTE
JTE

Reputation: 1321

I was having this same issue on various wireless carriers. I believe it was due to having many users worth of traffic funnel through the same external IP address used by the wireless carrier. Google sees these all as a single request source.

To fix, make sure you are appending your Google API key to the end of your request for the 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

Upvotes: 3

ghstcode
ghstcode

Reputation: 2912

This is a BB specific issue with Google's static maps API. The API rate limit is normal, but it pops up more often when using BB devices.

They seem to be using an IP pool and rotating those out to devices. This should in theory be a very intermittent issue. If you wait a few days hours, it should go away.

In other words, collectively, your IP has hit the static maps API more than 1000 times in a 24 hours period. This also happens when you hit the API too frequently within a short space of time.

My solution to this was to write a simple PHP script that requested the map image from Google once, saved it as a file and just served it instead of hitting the maps API each time.

Here's 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);

Upvotes: 3

Erik
Erik

Reputation: 1

I get this too, always, on a Blackberry. Don't think its usage limits, because I just woke up, and my total accesses = 1. Unless its some shared IP issue related to Blackberry.

Upvotes: 0

Argiropoulos Stavros
Argiropoulos Stavros

Reputation: 9533

You have exceeded the usage limits for the specific ip address

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

Upvotes: 5

Related Questions