Slide 1

Slide 1 text

Maptiles by MIERUNE, under CC BY. Data by OpenStreetMap contributors, under ODbL. Leaflet 初級編 MIERUNE Inc. / Yasunori Kirimoto 2017.06.30 FOSS4G 2017 Hokkaido ハンズオン - Web地図サイトを構築してみよう-

Slide 2

Slide 2 text

Maptiles by MIERUNE, under CC BY. Data by OpenStreetMap contributors, under ODbL. 地理空間情報エンジニア Yasunori Kirimoto

Slide 3

Slide 3 text

MIERUNE地図 Maptiles by MIERUNE, under CC BY. Data by OpenStreetMap contributors, under ODbL.

Slide 4

Slide 4 text

KIKI-TORI MAP 国立環境研究所(2017)KIKI-TORI マップ, 国立環境研究所 生物・生態系環境研究センター制作. ​http://www.nies.go.jp/kikitori/contents/map (2017/6/18 閲覧)

Slide 5

Slide 5 text

Contents はじめに ハンズオン その他事例

Slide 6

Slide 6 text

Introduction はじめに

Slide 7

Slide 7 text

事前準備できてますか?? http://day-journal.com/blog/day-016

Slide 8

Slide 8 text

HTML CSS JS Web Technology

Slide 9

Slide 9 text

JavaScript Library

Slide 10

Slide 10 text

OpenLayers 3

Slide 11

Slide 11 text

CESIUM

Slide 12

Slide 12 text

D3.js

Slide 13

Slide 13 text

Leaflet

Slide 14

Slide 14 text

Web Service

Slide 15

Slide 15 text

CARTO

Slide 16

Slide 16 text

Mapbox

Slide 17

Slide 17 text

Hands On ハンズオン

Slide 18

Slide 18 text

完成イメージ 基本構成 背景地図 コントロール オブジェクト GeoJSON プラグイン

Slide 19

Slide 19 text

demo demo

Slide 20

Slide 20 text

完成イメージ 基本構成 背景地図 コントロール オブジェクト GeoJSON プラグイン

Slide 21

Slide 21 text

index.html stylesheet.css script.js HTML CSS JS

Slide 22

Slide 22 text

フォルダ構成

Slide 23

Slide 23 text

初期表示状態

Slide 24

Slide 24 text

Leaflet Sample
HTML

Slide 25

Slide 25 text

html, body { height: 100%; padding: 0; margin: 0; } #map { z-index: 0; height: 100%; } CSS

Slide 26

Slide 26 text

完成イメージ 基本構成 背景地図 コントロール オブジェクト GeoJSON プラグイン

Slide 27

Slide 27 text

OpenStreetMap

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

var map = L.map('map'); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); map.setView([35.680899409847584, 139.76712226867676], 16); JS

Slide 30

Slide 30 text

地理院地図

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

L.tileLayer('https://cyberjapandata.gsi.go.jp/xyz/pale/{z}/{x}/{y}.png', { attribution: "国土地理院" }).addTo(map); JS

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

L.tileLayer('https://cyberjapandata.gsi.go.jp/xyz/ort/{z}/{x}/{y}.jpg', { attribution: "国土地理院" }).addTo(map); JS

Slide 35

Slide 35 text

MIERUNE地図

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

L.tileLayer('https://tile.mierune.co.jp/mierune_mono/{z}/{x}/{y}.png', { attribution: "Maptiles by MIERUNE, under CC BY. Data by OpenStreetMap contributors, under ODbL." }).addTo(map); JS

Slide 38

Slide 38 text

完成イメージ 基本構成 背景地図 コントロール オブジェクト GeoJSON プラグイン

Slide 39

Slide 39 text

レイヤ統合

Slide 40

Slide 40 text

var t_pale = new L.tileLayer('https://cyberjapandata.gsi.go.jp/xyz/pale/{z}/{x}/{y}.png', { attribution: "国土地理院" }); var t_ort = new L.tileLayer('https://cyberjapandata.gsi.go.jp/xyz/ort/{z}/{x}/{y}.jpg', { attribution: "国土地理院" }); var o_std = new L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }); var m_mono = new L.tileLayer('https://tile.mierune.co.jp/mierune_mono/{z}/{x}/{y}.png', { attribution: "Maptiles by MIERUNE, under CC BY. Data by OpenStreetMap contributors, under ODbL." }); JS

Slide 41

Slide 41 text

var lat = 35.680899409847584; var lng = 139.76712226867676; var map = L.map('map', { center: [lat, lng], zoom: 15, maxZoom: 18, zoomControl: true, layers: [m_mono] }); var Map_BaseLayer = { "地理院地図 淡色": t_pale, "地理院地図 オルソ": t_ort, "OpenStreetMap 標準": o_std, "MIERUNE地図 MONO": m_mono }; L.control.layers( Map_BaseLayer, null ).addTo(map); JS

Slide 42

Slide 42 text

レイヤ表示ON

Slide 43

Slide 43 text

L.control.layers( Map_BaseLayer, null, {collapsed:false} ).addTo(map); JS

Slide 44

Slide 44 text

スケール

Slide 45

Slide 45 text

L.control.scale({ imperial: false, maxWidth: 300 }).addTo(map); JS

Slide 46

Slide 46 text

ズームバー

Slide 47

Slide 47 text

var map = L.map('map', { center: [lat, lng], zoom: 15, maxZoom: 18, zoomControl: false, layers: [m_mono] }); JS

Slide 48

Slide 48 text

完成イメージ 基本構成 背景地図 コントロール オブジェクト GeoJSON プラグイン

Slide 49

Slide 49 text

マーカー

Slide 50

Slide 50 text

var Map_Point = L.marker( [35.68089940984, 139.7671222686] ).addTo(map); var comment = '東京駅だよ!!'; Map_Point.bindPopup(comment); JS

Slide 51

Slide 51 text

var IconPin01 = L.icon({ iconUrl: "./img/pin01.png", iconSize: [25, 25], iconAnchor: [0, 25], popupAnchor: [0, -35] }); var Map_Point = L.marker( [35.68089940984, 139.7671222686], { icon: IconPin01 } ).addTo(map); JS

Slide 52

Slide 52 text

ライン

Slide 53

Slide 53 text

var Map_Line = L.polyline([ [35.67500798914924,139.75952625274658], [35.67845922918971,139.76094245910645], [35.689369743530044,139.76420402526855] ],{ "color": "#2DE9C4", "weight": 5, "opacity": 0.6 }).addTo(map); JS

Slide 54

Slide 54 text

ポリゴン

Slide 55

Slide 55 text

var Map_Polygon = L.polygon([ [35.675949251235025,139.76617813110352], [35.67410157813001,139.77188587188718], [35.67455478492641,139.77227210998535], [35.683757812281115,139.77862358093262], [35.68431553740134,139.77343082427979], [35.68469897115985,139.77094173431396], [35.679923346539084,139.76871013641357], [35.675949251235025,139.76617813110352] ],{ "color": "#E92D63", "weight": 3, "opacity": 0.8, "fillColor": "#562DE9", "fillOpacity": 0.4 }).addTo(map); JS

Slide 56

Slide 56 text

オーバーレイヤ

Slide 57

Slide 57 text

var Map_AddLayer = { "Point": Map_Point, "Line": Map_Line, "Polygon": Map_Polygon }; L.control.layers( Map_BaseLayer, Map_AddLayer, {collapsed:false} ).addTo(map); JS

Slide 58

Slide 58 text

完成イメージ 基本構成 背景地図 コントロール オブジェクト GeoJSON プラグイン

Slide 59

Slide 59 text

データ準備

Slide 60

Slide 60 text

地理空間データ作成 : geojson.io

Slide 61

Slide 61 text

オープンデータ

Slide 62

Slide 62 text

国土数値情報(都市公園データ)を使用 QGIS : Shp → GeoJSON 変換

Slide 63

Slide 63 text

表示

Slide 64

Slide 64 text

var sampledata = { "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, "features": [ { "type": "Feature", "properties": { "P13_003": "北6条エルムの里公園" }, "geometry": { "type": "Point", "coordinates": [ 141.34308642, 43.0666937 ] } }, { "type": "Feature", "properties": { "P13_003": "宮部記念緑地" }, "geometry": { "type": "Point", "coordinates": [ 141.33550164, 43.0666937 ] } }, { "type": "Feature", "properties": { "P13_003": "偕楽園緑地" }, "geometry": { "type": "Point", "coordinates": [ 141.34429626, 43.06828667 ] } }, { "type": "Feature", "properties": { "P13_003": "八軒コスモス公園" }, "geometry": { "type": "Point", "coordinates": [ 141.32328053000001, 43.08470141 ] } } ] }; GeoJSON

Slide 65

Slide 65 text

HTML

Slide 66

Slide 66 text

var GeoJsonSample = L.geoJson(sampledata).addTo(map); JS

Slide 67

Slide 67 text

アレンジ

Slide 68

Slide 68 text

HTML

Slide 69

Slide 69 text

var lat = 42.333174; var lng = 141.004646; var IconPin02 = L.icon({ iconUrl: "./img/pin02.png", iconSize: [25, 25], iconAnchor: [15, 20], popupAnchor: [-5, -30] }); var PointAll = L.layerGroup().addTo(map); var PointGeojson = L.geoJson(pointdata, { onEachFeature: function (feature, layer) { var field ="目標地点: " + feature.properties.OBJECTID; layer.bindPopup(field); }, pointToLayer: function (feature, layer) { if (feature.properties.OBJECTID > 25) { return L.marker(layer, { icon: IconPin01 }); }else if (feature.properties.OBJECTID <= 25) { return L.marker(layer, { icon: IconPin02 }); } } }).addTo(PointAll); JS

Slide 70

Slide 70 text

var Map_AddLayer = { "目標地点": PointAll }; L.control.layers( Map_BaseLayer, Map_AddLayer, {collapsed:false} ).addTo(map); JS

Slide 71

Slide 71 text

HTML

Slide 72

Slide 72 text

var LineAll = L.layerGroup().addTo(map); var line_geojson = L.geoJson(linedata, { style: { "color": "#58BE89", "weight": 3, "opacity": 0.7, "dashArray":[10, 5] }, onEachFeature: function (feature, layer) { var field ="距離(m): " + feature.properties.Shape_len; layer.bindPopup(field); }, clickable: true }).addTo(LineAll); var Map_AddLayer = { "目標地点": PointAll, "避難経路": LineAll }; JS

Slide 73

Slide 73 text

HTML

Slide 74

Slide 74 text

var PolygonAll = L.layerGroup().addTo(map); var PolygonGeojson = L.geoJson(polygondata, { style: function(feature) { if (feature.properties.MEANmax_ < 2) { return { "color": "#90D6E5", "weight": 0.5, "fill": true, "fillColor":"#90D6E5", "fillOpacity":0.4 }; }else if (feature.properties.MEANmax_ >= 2 && feature.properties.MEANmax_ < 4) { return { "color": "#2A5CAA", "weight": 0.5, "fill": true, "fillColor":"#2A5CAA", "fillOpacity":0.4 }; }else if (feature.properties.MEANmax_ >= 4 && feature.properties.MEANmax_ < 6) { return { "color": "#F4EE4F", "weight": 0.5, "fill": true, "fillColor":"#F4EE4F", "fillOpacity":0.6 }; }else if (feature.properties.MEANmax_ >= 6 && feature.properties.MEANmax_ < 8) { JS

Slide 75

Slide 75 text

var Map_AddLayer = { "目標地点": PointAll, "避難経路": LineAll, "津波区域": PolygonAll }; JS

Slide 76

Slide 76 text

完成イメージ 基本構成 背景地図 コントロール オブジェクト GeoJSON プラグイン

Slide 77

Slide 77 text

©OpenStreetMap contributors Leaflet LocateControl

Slide 78

Slide 78 text

HTML

Slide 79

Slide 79 text

L.control.locate().addTo(map); JS

Slide 80

Slide 80 text

©OpenStreetMap contributors Leaflet Label

Slide 81

Slide 81 text

HTML

Slide 82

Slide 82 text

onEachFeature: function (feature, layer) { var field ="浸水深さ(m): " + feature.properties.MEANmax_; layer.bindLabel(field); } JS

Slide 83

Slide 83 text

Other Cases その他事例

Slide 84

Slide 84 text

その他のプラグイン

Slide 85

Slide 85 text

Leaflet.MultiTileLayer

Slide 86

Slide 86 text

©OpenStreetMap contributors Leaflet Minimap

Slide 87

Slide 87 text

Leaflet.heat

Slide 88

Slide 88 text

©OpenStreetMap contributors Leaflet Draw

Slide 89

Slide 89 text

Leaflet-icon-pulse

Slide 90

Slide 90 text

©OpenStreetMap contributors Leaflet MeasureControl

Slide 91

Slide 91 text

Leaflet Animated Marker

Slide 92

Slide 92 text

©OpenStreetMap contributors Leaflet Routing Machine

Slide 93

Slide 93 text

ハイブリッドアプリ

Slide 94

Slide 94 text

CORDOVA

Slide 95

Slide 95 text

PhoneGap

Slide 96

Slide 96 text

Monaca

Slide 97

Slide 97 text

使い方

Slide 98

Slide 98 text

新規プロジェクトの作成

Slide 99

Slide 99 text

プロジェクト選択

Slide 100

Slide 100 text

ファイルをインポート

Slide 101

Slide 101 text

プレビュー機能・実機検証

Slide 102

Slide 102 text

CARTO,Mapboxと連携

Slide 103

Slide 103 text

みんなの公園マップ - 札幌版 -

Slide 104

Slide 104 text

Leaflet

Slide 105

Slide 105 text

CARTO

Slide 106

Slide 106 text

Mapbox

Slide 107

Slide 107 text

Maptiles by MIERUNE, under CC BY. Data by OpenStreetMap contributors, under ODbL. おつかれさまでした!