Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/gagan-bansal/google-maps-large-size-image
- Owner: gagan-bansal
- License: mit
- Created: 2022-08-15T07:45:13.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-19T16:02:27.000Z (12 months ago)
- Last Synced: 2024-04-13T16:19:42.543Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 82 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.