Leafletサンプル集|いますぐ試せるWeb地図61パターン

GIS基礎

はじめに

Web地図の作成は難しいと感じる初心者でも、オープンソースのJavaScriptライブラリ「Leaflet」を使えば簡単にインタラクティブなマップを作成できます。本記事ではLeafletを使った地図作成の入門に役立つ豊富なサンプルを紹介します。

Leafletとは

Leafletは、軽量で使いやすく、モバイル端末にも最適化されたJavaScriptライブラリです。簡単なコードで高機能な地図を作成でき、地理情報の可視化、ルーティング、ヒートマップ、3D表示など幅広い用途で利用されています。

  • 初心者にも扱いやすい直感的なAPI
  • 豊富なプラグインや拡張機能
  • オープンソースで自由に利用可能

またLeafletのサンプルはHTMLファイルとして保存できるため、作った地図をローカル環境でそのまま開いたり、スマートフォンに転送して閲覧したりすることも可能です。オフラインでの利用や持ち運びにも便利なので、ぜひ自分用の地図コレクションを作ってみてください。

サンプル紹介

以下にLeafletの便利な機能を初心者でもすぐ理解・実装できるよう、61個のサンプルをリストアップしました。各リンク先には実際のコードや動作例があり、簡単に試すことができます。

No機能名説明サンプル
1Map地図を生成・表示し、初期中心座標やズームレベルを設定https://gisaca.net/leaflet/01_map.html
2Tile Layer背景地図タイルを読み込み表示https://gisaca.net/leaflet/02_tilelayer.html
3TileLayer.WMSOGC WMSサービスをタイルレイヤーとして表示https://gisaca.net/leaflet/03_tilelayer_wms.html
4LayerGroup複数レイヤーをグループ化して一括操作https://gisaca.net/leaflet/04_layergroup.html
5FeatureGroupグループ内の全レイヤーに対し一括イベントやスタイル適用https://gisaca.net/leaflet/05_featuregroup.html
6Zoomingズームイン・ズームアウトを操作(ホイール・ボタン・ピンチ)https://gisaca.net/leaflet/06_zooming.html
7Panning地図のドラッグ移動(慣性あり)https://gisaca.net/leaflet/07_panning.html
8Double-click & Box Zoomダブルクリックやボックス選択でのズームhttps://gisaca.net/leaflet/08_boxzoom.html
9LatLng & distanceTo座標オブジェクトと距離計算https://gisaca.net/leaflet/09_distanceto.html
10Map Eventsクリック・ズーム・移動など多彩なイベント処理https://gisaca.net/leaflet/10_mapevents.html
11Map Options初期設定・ズーム制限・表示範囲制限などhttps://gisaca.net/leaflet/11_mapoption.html
12CRS (座標系)地図投影法・座標参照系の設定https://gisaca.net/leaflet/12_crs.html
13Retina対応高DPIディスプレイ向けに2倍解像度タイルを読み込みhttps://gisaca.net/leaflet/13_retina.html
14Animationズーム・パン操作にスムーズなアニメーションhttps://gisaca.net/leaflet/14_animation.html
15Performance (Mobile)タッチ操作最適化やモジュール化で軽快動作https://gisaca.net/leaflet/15_mobile.html
16Marker地図上にアイコンを配置https://gisaca.net/leaflet/16_marker.html
17Draggable Markerマーカーをドラッグで移動可能にhttps://gisaca.net/leaflet/17_draggable_marker.html
18Icon/DivIconカスタム画像やHTMLマーカーの設定https://gisaca.net/leaflet/18_divicon.html
19Popup吹き出し状の情報ボックス表示https://gisaca.net/leaflet/19_popup.html
20Tooltipホバー時に表示される簡易ラベルhttps://gisaca.net/leaflet/20_tooltip.html
21Polyline折れ線(ルート)描画https://gisaca.net/leaflet/21_polyline.html
22Polygon塗りつぶし多角形描画https://gisaca.net/leaflet/22_polygon.html
23Rectangle矩形描画https://gisaca.net/leaflet/23_rectangle.html
24Circle半径指定の円描画https://gisaca.net/leaflet/24_circle.html
25CircleMarkerピクセル半径の固定円マーカーhttps://gisaca.net/leaflet/25_circlemarker.html
26ImageOverlay指定範囲に画像を重ねるhttps://gisaca.net/leaflet/26_imageoverlay.html
27VideoOverlay指定範囲に動画を重ねるhttps://gisaca.net/leaflet/27_videooverlay.html
28GeoJSON LayerGeoJSONデータを地図に表示https://gisaca.net/leaflet/28_geojsonlayer.html
29GeoJSON Filter属性条件でGeoJSONをフィルタhttps://gisaca.net/leaflet/29_geojsonfilter.html
30Interactive Layerレイヤーのクリック・ホバー反応設定https://gisaca.net/leaflet/30_interactivelayer.html
31Path Styling線・面の色・太さ・透明度設定https://gisaca.net/leaflet/31_pathstyling.html
32Zoom Control+/-ボタンによるズームhttps://gisaca.net/leaflet/32_zoomcontrol.html
33Scale Control縮尺バーを表示https://gisaca.net/leaflet/33_scalecontrol.html
34Attribution Control著作権表記の表示https://gisaca.net/leaflet/34_attributioncontrol.html
35Layers Controlベース/オーバーレイレイヤー切替UIhttps://gisaca.net/leaflet/35_layerscontrol.html
36Custom Control独自コントロールを作成・配置https://gisaca.net/leaflet/36_customcontrol.html
37Fullscreen Control全画面表示切替ボタンhttps://gisaca.net/leaflet/37_fullscreencontrol.html
38MiniMap小縮尺の概要図表示https://gisaca.net/leaflet/38_minimap.html
39Mouse Coordinatesカーソル位置の緯度経度表示https://gisaca.net/leaflet/39_mousecoordinates.html
40Measure Tool距離・面積の計測https://gisaca.net/leaflet/40_measuretool.html
41Sidebar地図横に情報パネル追加https://gisaca.net/leaflet/41_sidebar.html
42EasyButtonアイコン付きボタン簡易追加https://gisaca.net/leaflet/42_easybutton.html
43Geocoder住所検索ボックス追加https://gisaca.net/leaflet/43_geocoder.html
44Reverse Geocodingクリック地点の住所取得https://gisaca.net/leaflet/44_reversegeocoding.html
45Search Controlレイヤー内データのテキスト検索https://gisaca.net/leaflet/45_searchcontrol.html
46Tag Filterタグ別にポイント絞り込みhttps://gisaca.net/leaflet/46_tagfilter.html
47Autocomplete Search入力補完付き検索ボックスhttps://gisaca.net/leaflet/47_autocompletesearch.html
48Nearby Search近傍POIの取得・表示https://gisaca.net/leaflet/48_nearbysearch.html
49Dynamic Filtering属性に応じて表示OFF/ON制御https://gisaca.net/leaflet/49_dynamicfiltering.html
50Marker Clustering多数マーカーをクラスター化https://gisaca.net/leaflet/50_markerclustering.html
51Heatmap密度ヒートマップ表示https://gisaca.net/leaflet/51_heatmap.html
52Draw & Edit図形描画・編集ツール提供https://gisaca.net/leaflet/52_drawedit.html
53Routing Machine経路検索・ルーティング表示https://gisaca.net/leaflet/53_routingmachine.html
54Hotline/Choropleth値に応じたライン/面のグラデーションhttps://gisaca.net/leaflet/54_hotline.html
55PlaybackGPS軌跡アニメーション再生https://gisaca.net/leaflet/55_playback.html
56Elevation高度プロファイル(断面図)表示https://gisaca.net/leaflet/56_elevation.html
573D/MaplibreMapLibre GL JSによる3D表示https://gisaca.net/leaflet/57_3dmaplibre.html
58omnivore多形式ファイルをGeoJSON化https://gisaca.net/leaflet/58_omnivore.html
59ShapefileShapefileを直接ブラウザ表示https://gisaca.net/leaflet/59_shapefile.html
60easyPrint地図の画像保存・印刷機能追加https://gisaca.net/leaflet/60_easyprint.html
61DataViz Integrationチャートを地図上に表示https://gisaca.net/leaflet/61_datavizintegration.html

まとめ

Leafletを使えば、初心者でも簡単に様々な地図をWeb上に作成・公開できます。今回紹介したサンプルを参考に、ぜひ実際に触れて理解を深めてみてください。今後も豊富なプラグインや機能を活用し、さらに魅力的なWeb地図を作りましょう。

コメント

  1. Hello there, I found your site by way of Google even as looking for a similar topic, your website came up, it looks good.
    I’ve bookmarked it in my google bookmarks.
    Hello there, simply turned into alert to your blog through Google,
    and located that it’s really informative. I’m
    going to be careful for brussels. I will appreciate if you continue this
    in future. Many folks can be benefited out of your writing.
    Cheers!

タイトルとURLをコピーしました