百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

mapkick

> 编程语言
开源

使用一行 Ruby 代码创建美观的 JavaScript 地图

302 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

使用一行 Ruby 代码创建美观的 JavaScript 地图

Mapkick

Create beautiful JavaScript maps with one line of Ruby. No more fighting with mapping libraries!

See it in action

:fire: For static maps, check out Mapkick Static, and for charts, check out Chartkick

Installation

Add this line to your application’s Gemfile:

ruby
gem "mapkick-rb"

Mapkick uses Mapbox GL JS v1. To use tiles from Mapbox, create a Mapbox account to get an access token and set ENV["MAPBOX_ACCESS_TOKEN"] in your environment (or set Mapkick.options[:access_token] in an initializer).

Then follow the instructions for your JavaScript setup:

  • Importmap (Rails default)
  • Bun, esbuild, rollup.js, or Webpack
  • Sprockets

Importmap

In config/importmap.rb, add:

ruby
pin "mapkick/bundle", to: "mapkick.bundle.js"

And in app/javascript/application.js, add:

javascript
import "mapkick/bundle"

Bun, esbuild, rollup.js, or Webpack

Run:

bash
bun add mapkick
# or
yarn add mapkick

And in app/javascript/application.js, add:

javascript
import "mapkick/bundle"

Sprockets

In app/assets/javascripts/application.js, add:

javascript
//= require mapkick.bundle

Maps

Point map

erb

Area map

erb

Data

Data can be an array

erb

Or a URL that returns JSON (same format as above)

erb

Point Map

Use latitude or lat for latitude and longitude, lon, or lng for longitude

You can specify a label, tooltip, and color for each data point

ruby
{
  latitude: ...,
  longitude: ...,
  label: "Hot Chicken Takeover",
  tooltip: "5 stars",
  color: "#f84d4d"
}

Area Map

Use geometry with a GeoJSON Polygon or MultiPolygon

You can specify a label, tooltip, and color for each data point

ruby
{
  geometry: {type: "Polygon", coordinates: ...},
  label: "Hot Chicken Takeover",
  tooltip: "5 stars",
  color: "#0090ff"
}

Options

Id, width, and height

erb

Marker color

erb

Show tooltips on click instead of hover

erb

Allow HTML in tooltips (must sanitize manually)

erb

Map style

erb

Zoom and controls

erb

Refresh data from a remote source every n seconds

erb

Pass options directly to the mapping library

erb

See the documentation for Mapbox GL JS for more info

Global Options

To set options for all of your maps, create an initializer config/initializers/mapkick.rb with:

ruby
Mapkick.options[:height] = "400px"

Sinatra and Padrino

Download mapkick.bundle.js and include it manually.

xml

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

  • Report bugs
  • Fix bugs and submit pull requests
  • Write, clarify, or fix documentation
  • Suggest or add new features

To get started with development:

bash
git clone https://github.com/ankane/mapkick.git
cd mapkick
bundle install
bundle exec rake test

Issues· 4 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言