Urgent.News

What's breaking now, across thousands of outlets.

Tech

Put a real map on your page with plain HTML — no API key, no per-view bill, no tile server

Most sites that need a map end up with one of three options. The first is a commercial map API that bills per view. The second is the OpenStreetMap tile server, but its Tile Usage Policy rules out commercial and heavy-traffic use. The third is a tile server you run yourself, which you then have to keep running. There is a fourth option, because almost nobody needs the whole planet . You need the…

Many websites rely on three main map options. The first is a commercial map API, which charges per view. The second option is the OpenStreetMap tile server, but its usage policy disallows commercial and heavy-traffic utilization. The third choice involves setting up your own tile server, which you must then maintain.

However, there is an additional option available, as MMJ, an open-source set of Web Components plus a tool for extracting map tiles, demonstrates. By borrowing the map data and owning the appearance, MMJ allows you to focus on the specifics of your site.

MMJ simplifies the process by cutting your area into a single file. With just one command, you can generate a PMTiles file from a bounding box provided by the Protomaps daily build of the entire planet. A city-sized map ranges from 10-60 MB and is produced within a minute. Serving this file on static hosting means your website will only need to deploy this file, reducing your hosting costs.

The eight custom elements, written as plain ES modules, render the map using MapLibre. These elements include mmj-map, mmj-marker, mmj-poi, mmj-cluster, mmj-route, mmj-circle, mmj-raster, and mmj-fill. To use MMJ, install the necessary components and follow the provided installation guide. The project is available in multiple languages, including Japanese, Traditional Chinese, Simplified Chinese, and Vietnamese.

Remember to display the © OpenStreetMap contributors notice on the map, as the data is licensed under the ODbL, while the code, styles, and components are under the MIT license.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

在多台远程服务器上并行跑 Codex:worktree 应该怎么分

并行跑 AI 任务,常见的阻碍往往不是模型能力,而是目录。 两个会话在同一个工作目录里改代码,A 刚写完的文件可能被 B 覆盖;你打开文件准备保存,界面提示版本已经过期;测试失败时,也很难判断是哪一个任务改坏的。机器一多,问题还会多一层:任务到底跑在哪台服务器、哪个目录、哪个分支? Git worktree 能解决其中一部分问题,但它不是「把同一个目录挂到多台机器」的魔法。这篇讲清楚…

What should a vector editor remember after you hide its panels?

A familiar editor layout has to do more than resemble its reference. In Si, our browser-based vector editor, the workspace must distinguish a persistent preference from a temporary interaction.

  • Si browser vector editor has three hiding levels: allHidden, sideHidden, collapsed
  • reducer toggles hiding fields independently, panel selection clears flags
  • writeWorkspace persists layout in local storage with allHidden, sideHidden, tool fields

More from Monday 2 November →