Atlaslog
Atlaslog / Leaflet / Tutorial / Mobile and touch adaptation
Leaflet · Tutorial

Mobile and touch adaptation

Quick answer

This tutorial adapts a Leaflet map to phones, starting with 100dvh instead of 100vh and the viewport meta tag with viewport-fit=cover for safe areas. It reviews touch-related options such as touchZoom, inertia, doubleClickZoom and zoomControl, and shows how to enlarge hit areas to 44 logical pixels. It also resolves scroll-versus-drag conflicts with touch-action and re-measures the map after orientation changes.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
Key points
Example
html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;    /* 阻止下拉刷新与橡皮筋效果 */
}

#map {
  height: 100vh;                /* 老浏览器回退 */
  height: 100dvh;               /* 随地址栏变化 */
  padding-bottom: env(safe-area-inset-bottom);
}
<meta name="viewport"
      content="width=device-width, initial-scale=1, viewport-fit=cover">
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Mobile and touch adaptation. https://www.jingweizhi.com/en/leaflet/tutorials/mobile.html (accessed 2026-11-03).