Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gagan-bansal/google-maps-large-size-image

Create high resolution and large size Google Maps image.
https://github.com/gagan-bansal/google-maps-large-size-image

Last synced: about 7 hours ago
JSON representation

Create high resolution and large size Google Maps image.

Awesome Lists containing this project

README

        

# google-maps-large-size-image

Fetch high resolution large size maps image from Google Maps by passing maps extent and zoom level.

## Features

## :hammer: Installation

Use npm or compatible tool.

```shell
npm install google-maps-large-size-image
```

## :popcorn: Usage

This library is based on [Google Maps Static API](https://developers.google.com/maps/documentation/maps-static/overview). The [API key](https://developers.google.com/maps/documentation/maps-static/get-api-key) for the same is required.

```javascript
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!');
})();

```

## :blue_car: API

### new LargMap(googleMapsAPIKye, options?)

Return an instance to fetch map images by passing [API key](https://developers.google.com/maps/documentation/maps-static/get-api-key).

#### options

JSON object that can have google static map [parameters](https://developers.google.com/maps/documentation/maps-static/start#map-parameters). `scale` parameter is the key to get high resolution image, please read more in [API documentation](https://developers.google.com/maps/documentation/maps-static/start#scale_values).

#### Method

* **getImage(extent, zoom?)**

`extent` an array of coordinates:
```javascript
[
bottom left long,
bottom left lat,
top right long,
top right lat
]
```
`zoom` integer, zoom level of Google Maps. Default value is 8.