Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ankane/mapkick-static
Create beautiful static maps with one line of Ruby
https://github.com/ankane/mapkick-static
Last synced: about 1 month ago
JSON representation
Create beautiful static maps with one line of Ruby
- Host: GitHub
- URL: https://github.com/ankane/mapkick-static
- Owner: ankane
- License: mit
- Created: 2023-04-26T09:05:43.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-23T14:38:29.000Z (4 months ago)
- Last Synced: 2024-07-14T23:02:19.346Z (2 months ago)
- Language: Ruby
- Homepage:
- Size: 15.6 KB
- Stars: 65
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Mapkick Static
Create beautiful static maps with one line of Ruby. No more fighting with mapping libraries!
[See it in action](#maps)
:fire: For JavaScript maps, check out [Mapkick](https://chartkick.com/mapkick)
[![Build Status](https://github.com/ankane/mapkick-static/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/mapkick-static/actions)
## Installation
Add this line to your application’s Gemfile:
```ruby
gem "mapkick-static"
```Mapkick Static uses the [Mapbox Static Images API](https://docs.mapbox.com/api/maps/static-images/). [Create a Mapbox account](https://account.mapbox.com/auth/signup/) to get an access token and set `ENV["MAPBOX_ACCESS_TOKEN"]` in your environment.
## Maps
Point map
```erb
<%= static_map [{latitude: 37.7829, longitude: -122.4190}] %>
```Area map
```erb
<%= static_area_map [{geometry: {type: "Polygon", coordinates: ...}}] %>
```## Data
Data can be an array
```erb
<%= static_map [{latitude: 37.7829, longitude: -122.4190}] %>
```### Point Map
Use `latitude` or `lat` for latitude and `longitude`, `lon`, or `lng` for longitude
You can specify a color for each data point
```ruby
{
latitude: ...,
longitude: ...,
color: "#f84d4d"
}
```### Area Map
Use `geometry` with a GeoJSON `Polygon` or `MultiPolygon`
You can specify a color for each data point
```ruby
{
geometry: {type: "Polygon", coordinates: ...},
color: "#0090ff"
}
```## Options
Width and height
```erb
<%= static_map data, width: 800, height: 500 %>
```Alt text
```erb
<%= static_map data, alt: "Map of ..." %>
```Marker color
```erb
<%= static_map data, markers: {color: "#f84d4d"} %>
```Map style
```erb
<%= static_map data, style: "mapbox/outdoors-v12" %>
```## History
View the [changelog](https://github.com/ankane/mapkick-static/blob/master/CHANGELOG.md)
## Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- [Report bugs](https://github.com/ankane/mapkick-static/issues)
- Fix bugs and [submit pull requests](https://github.com/ankane/mapkick-static/pulls)
- Write, clarify, or fix documentation
- Suggest or add new featuresTo get started with development:
```sh
git clone https://github.com/ankane/mapkick-static.git
cd mapkick-static
bundle install
bundle exec rake test
```