google-map-static-image-generator 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +49 -0
- data/google-map-static-image-generator.gemspec +21 -0
- data/lib/google_map_static_image/version.rb +3 -0
- data/lib/google_map_static_image.rb +18 -21
- metadata +62 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: dd7cf0d91c5296a1352f60e6989066ffc156431d5956e7ce52599f5c7d66e2f2
|
|
4
|
+
data.tar.gz: 9ca9c456a6a84d9083c1f81325305cd98eb907fc76adce18de79ca52d6ff519d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11676470fad2e0a0f43f8b9e8350f4efdb41415b9ae4baa0c31a3c606771c754ab3d0345801476ed33dc0d3720fa60b3bb8178b3c9765c8dc0080f022e726fed
|
|
7
|
+
data.tar.gz: f020ffdfcc0ec13cbc8155205b027c9bd2fd2a99f1ca4d4840a93d67b78b32c9c72599a37f58748044f771dd8ae4b8f136ab51fce90b08e86718b1b1e0b0715c
|
data/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# google-map-static-image-generator
|
|
2
|
+
|
|
3
|
+
A Ruby gem that wraps the [Google Maps Static API](https://developers.google.com/maps/documentation/maps-static/overview) to generate customizable static map images in Rails applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your `Gemfile`:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'google-map-static-image-generator'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bundle install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
map = GoogleMapStaticImage.new
|
|
23
|
+
|
|
24
|
+
response = map.get_response(
|
|
25
|
+
"YOUR_GOOGLE_API_KEY",
|
|
26
|
+
markers, # array of marker coordinate strings
|
|
27
|
+
style: { feature: "all", element: "labels", visibility: "off" },
|
|
28
|
+
path: { weight: 3, color: "blue" },
|
|
29
|
+
location: { lat: "48.8584", lng: "2.2945" },
|
|
30
|
+
markers: [["48.8584,2.2945"], ["48.8606,2.3376"]]
|
|
31
|
+
)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The response is the raw parsed response from the Google Static Maps API — typically image binary data or a redirect URL depending on your usage.
|
|
35
|
+
|
|
36
|
+
## Options
|
|
37
|
+
|
|
38
|
+
| Option | Description |
|
|
39
|
+
|--------|-------------|
|
|
40
|
+
| `style` | Map style rules as a hash (`key: value` pairs joined with `\|`) |
|
|
41
|
+
| `path` | Path styling options (weight, color, etc.) |
|
|
42
|
+
| `location` | Hash of `lat`/`lng` to append to the path |
|
|
43
|
+
| `markers` | Array of marker groups; each group is an array of coordinate strings |
|
|
44
|
+
|
|
45
|
+
The default image size is `1024x1024` at scale `2`.
|
|
46
|
+
|
|
47
|
+
## Dependencies
|
|
48
|
+
|
|
49
|
+
- [httparty](https://github.com/jnunemaker/httparty)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require_relative "lib/google_map_static_image/version"
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "google-map-static-image-generator"
|
|
5
|
+
spec.version = GoogleMapStaticImage::VERSION
|
|
6
|
+
spec.authors = ["Abhishek Sharma"]
|
|
7
|
+
spec.email = ["abhsss96@gmail.com"]
|
|
8
|
+
spec.summary = "Generate static map images using the Google Maps Static API"
|
|
9
|
+
spec.description = "Wraps the Google Maps Static API to generate customizable static map images with markers, paths, and styles."
|
|
10
|
+
spec.homepage = "https://github.com/abhsss96/google-map-static-image-generator"
|
|
11
|
+
spec.license = "MIT"
|
|
12
|
+
spec.required_ruby_version = ">= 2.7"
|
|
13
|
+
|
|
14
|
+
spec.files = Dir["lib/**/*", "README.md", "*.gemspec"]
|
|
15
|
+
spec.require_paths = ["lib"]
|
|
16
|
+
|
|
17
|
+
spec.add_dependency "httparty", ">= 0.14"
|
|
18
|
+
|
|
19
|
+
spec.add_development_dependency "rspec", "~> 3.12"
|
|
20
|
+
spec.add_development_dependency "webmock", "~> 3.0"
|
|
21
|
+
end
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
+
require "httparty"
|
|
2
|
+
require_relative "google_map_static_image/version"
|
|
3
|
+
|
|
1
4
|
class GoogleMapStaticImage
|
|
2
|
-
|
|
3
|
-
require "debugger"
|
|
4
|
-
def get_response(api_key,markers,option={})
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
url = "https://maps.googleapis.com/maps/api/staticmap"
|
|
8
|
-
url1= "http://192.168.0.19:3041"
|
|
9
|
-
|
|
10
|
-
query = Hash.new
|
|
11
|
-
query[:api_key] = api_key
|
|
12
|
-
query[:size] = "1024x1024"
|
|
13
|
-
query[:scale] = 2
|
|
14
|
-
query[:style] = option[:style].map {|key,val| "#{key}:#{val}"}.join("|") unless option[:style].nil?
|
|
15
|
-
query[:path] = option[:path].map {|key,val| "#{key}:#{val}"}.join("|") unless option[:path].nil?
|
|
16
|
-
query[:path] = [query[:path],option[:location].map {|key,val| "#{val}"}.join("|")].join("|") unless option[:location].nil?
|
|
17
|
-
query[:markers] = option[:markers].map { |val| val.join("|")} unless option[:markers].nil?
|
|
18
|
-
|
|
19
|
-
response = HTTParty.get("#{url1}", :query=>query)
|
|
20
|
-
response = HTTParty.get("#{url}", :query=>query)
|
|
21
|
-
return response.parsed_response
|
|
5
|
+
STATIC_MAP_URL = "https://maps.googleapis.com/maps/api/staticmap"
|
|
22
6
|
|
|
23
|
-
|
|
7
|
+
def get_response(api_key, markers, option = {})
|
|
8
|
+
query = {}
|
|
9
|
+
query[:api_key] = api_key
|
|
10
|
+
query[:size] = "1024x1024"
|
|
11
|
+
query[:scale] = 2
|
|
12
|
+
query[:style] = option[:style].map { |key, val| "#{key}:#{val}" }.join("|") unless option[:style].nil?
|
|
13
|
+
query[:path] = option[:path].map { |key, val| "#{key}:#{val}" }.join("|") unless option[:path].nil?
|
|
14
|
+
unless option[:location].nil?
|
|
15
|
+
query[:path] = [query[:path], option[:location].map { |_key, val| val.to_s }.join("|")].join("|")
|
|
16
|
+
end
|
|
17
|
+
query[:markers] = option[:markers].map { |val| val.join("|") } unless option[:markers].nil?
|
|
24
18
|
|
|
19
|
+
response = HTTParty.get(STATIC_MAP_URL, query: query)
|
|
20
|
+
response.parsed_response
|
|
21
|
+
end
|
|
25
22
|
end
|
metadata
CHANGED
|
@@ -1,45 +1,90 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: google-map-static-image-generator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Abhishek Sharma
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
date: 2026-05-31 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: httparty
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.14'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.14'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '3.12'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '3.12'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: webmock
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description: Wraps the Google Maps Static API to generate customizable static map
|
|
56
|
+
images with markers, paths, and styles.
|
|
57
|
+
email:
|
|
58
|
+
- abhsss96@gmail.com
|
|
15
59
|
executables: []
|
|
16
60
|
extensions: []
|
|
17
61
|
extra_rdoc_files: []
|
|
18
62
|
files:
|
|
63
|
+
- README.md
|
|
64
|
+
- google-map-static-image-generator.gemspec
|
|
19
65
|
- lib/google_map_static_image.rb
|
|
20
|
-
|
|
66
|
+
- lib/google_map_static_image/version.rb
|
|
67
|
+
homepage: https://github.com/abhsss96/google-map-static-image-generator
|
|
21
68
|
licenses:
|
|
22
|
-
-
|
|
69
|
+
- MIT
|
|
23
70
|
metadata: {}
|
|
24
|
-
post_install_message:
|
|
71
|
+
post_install_message:
|
|
25
72
|
rdoc_options: []
|
|
26
73
|
require_paths:
|
|
27
74
|
- lib
|
|
28
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
76
|
requirements:
|
|
30
|
-
- -
|
|
77
|
+
- - ">="
|
|
31
78
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
79
|
+
version: '2.7'
|
|
33
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
81
|
requirements:
|
|
35
|
-
- -
|
|
82
|
+
- - ">="
|
|
36
83
|
- !ruby/object:Gem::Version
|
|
37
84
|
version: '0'
|
|
38
85
|
requirements: []
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
signing_key:
|
|
86
|
+
rubygems_version: 3.5.22
|
|
87
|
+
signing_key:
|
|
42
88
|
specification_version: 4
|
|
43
|
-
summary:
|
|
44
|
-
with different params
|
|
89
|
+
summary: Generate static map images using the Google Maps Static API
|
|
45
90
|
test_files: []
|