SilverTear
SilverTear

Reputation: 733

Google Static Maps API scale & size

I am a bit confused with the new billing model for the google static maps API. Previously, you needed a premium plan API to request images larger than 640 x 480. With the new pay-as-you-go pricing model (as of 16th of July), do you still need a premium plan to be able to get bigger images, or can I just enable billing and request these bigger images? I enabled billing and used a signed url to get an image of 2000x2000 pixels (scale=1), but it didn't work as I got back an image of 640x480. Am I missing something, or do I still need a premium plan to achieve this?

Upvotes: 3

Views: 3004

Answers (2)

Gagan
Gagan

Reputation: 1343

I had similar requirement, and could not find any solution. So I have have created a module google-maps-large-size-image that solves the issue of getting large size high resolution image from Google Static Maps.

Here is the usage example:

const fs = require('fs').promises;
const path = require('path');
const {LargeMap} = require('google-maps-large-size-image');
require('dotenv').config();

// initiate the LargeMap instance
const lm = new LargeMap(process.env.GOOGLE_MAPS_API_KEY, {
  scale: 2,
  mapType: 'terrain',
  region: 'in',
  style: 'feature:road|color:yellow'
});

(async () => {
  const extent = [72.61, 18.76, 75.28, 21.62];
  const zoom = 10;
  try {
    const img = await lm.getImage(extent, zoom);
    await fs.writeFile(path.join(process.cwd(), '/output.jpg'), img);
  } catch (err) {
    console.error(err);
  }
  console.log('done!');
})();

Link for npm module google-maps-large-size-image.

Upvotes: 1

xomena
xomena

Reputation: 32178

At the moment only Premium plan users have a high resolution 2048x2048 images by default. New Google Maps Platform doesn't have this feature enabled yet. There is a feature request in Google issue tracker to make these images available for Google Maps Platform as well. You can see the feature request here:

https://issuetracker.google.com/issues/110570733

Feel free to star it to add your vote and subscribe to further notifications from Google.

Update

Google marked a feature request as solved with the following statement

We now have an update on this issue: access to 2048x2048 Static Maps will be granted on a case by case basis. Please create a support case to open a personalized communication channel https://support.google.com/googleapi/contact/maps_api_tech_support

Upvotes: 5

Related Questions