Merge pull request #24 from kazu634/leaflet-mapbox-js-support

Leaflet mapbox js support
This commit is contained in:
Kazuhiro MUSASHI 2019-05-01 21:28:17 +07:00 committed by GitHub
commit 713d0787b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 170 additions and 0 deletions

View File

@ -0,0 +1,63 @@
+++
title = "JavaScriptではじめるWebマップアプリケーション: Chapter2-1"
date = 2019-05-01T19:06:46+08:00
Description = "JavaScriptではじめるWebマップアプリケーションの内容を淡々と試してみます。"
Categories = ["Leaflet.js"]
+++
『[JavaScriptではじめるWebマップアプリケーション \(PDF版\)](https://booth.pm/ja/items/1314906)』の内容を淡々と試してみます。まずは`Leaflet.js`で地図を表示してみます:
<div id="leaflet-map"></div>
<style type="text/css">
<!--
#leaflet-map { height: 600px; }
-->
</style>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<link href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" rel="stylesheet">
<script>
// MIERUNE MONO読み込み
let m_mono = new L.tileLayer("https://tile.mierune.co.jp/mierune_mono/{z}/{x}/{y}.png", {
attribution: "Maptiles by <a href='http://mierune.co.jp/' target='_blank'>MIERUNE</a>, under CC BY. Data by <a href='http://osm.org/copyright' target='_blank'>OpenStreetMap</a> contributors, under ODbL."
});
// Map読み込み
let map = L.map("leaflet-map", {
center: [35.6810,139.7670],
zoom: 14,
layers: [m_mono]
});
</script>
## コード
このような形になります:
```
<div id="leaflet-map"></div>
<style type="text/css">
<!--
#leaflet-map { height: 600px; }
-->
</style>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<link href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" rel="stylesheet">
<script>
// MIERUNE MONO読み込み
let m_mono = new L.tileLayer("https://tile.mierune.co.jp/mierune_mono/{z}/{x}/{y}.png", {
attribution: "Maptiles by <a href='http://mierune.co.jp/' target='_blank'>MIERUNE</a>, under CC BY. Data by <a href='http://osm.org/copyright' target='_blank'>OpenStreetMap</a> contributors, under ODbL."
});
// Map読み込み
let map = L.map("leaflet-map", {
center: [35.6810,139.7670],
zoom: 14,
layers: [m_mono]
});
</script>
```

View File

@ -0,0 +1,107 @@
+++
title = "JavaScriptではじめるWebマップアプリケーション: Chapter2-2"
date = 2019-05-01T21:07:08+07:00
Description = "JavaScriptではじめるWebマップアプリケーションの内容を淡々と試してみます。"
Categories = ["Mapbox GL JS"]
+++
『[JavaScriptではじめるWebマップアプリケーション \(PDF版\)](https://booth.pm/ja/items/1314906)』の内容を淡々と試してみます。`Mapbox GL JS`で地図を表示してみます:
<div id="mapbox-map"></div>
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.js"></script>
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.css" rel="stylesheet">
<style type="text/css">
<!--
#mapbox-map {
height: 600px;
}
-->
</style>
<script>
// MIERUNE MONO読み込み
let map = new mapboxgl.Map({
container: "mapbox-map",
style: {
version: 8,
sources: {
m_mono: {
type: "raster",
tiles: ["https://tile.mierune.co.jp/mierune_mono/{z}/{x}/{y}.png"],
tileSize: 256
}
},
layers: [{
id: "m_mono",
type: "raster",
source: "m_mono",
minzoom: 0,
maxzoom: 18
}]
},
center: [139.7670, 35.6810],
zoom: 13
});
map.on("load", function() {
});
// ズームコントロール
let nc = new mapboxgl.NavigationControl();
map.addControl(nc, 'top-left');
</script>
## コード
こんな形になります:
```
<div id="mapbox-map"></div>
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.js"></script>
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.css" rel="stylesheet">
<style type="text/css">
<!--
#mapbox-map {
height: 600px;
}
-->
</style>
<script>
// MIERUNE MONO読み込み
let map = new mapboxgl.Map({
container: "mapbox-map",
style: {
version: 8,
sources: {
m_mono: {
type: "raster",
tiles: ["https://tile.mierune.co.jp/mierune_mono/{z}/{x}/{y}.png"],
tileSize: 256
}
},
layers: [{
id: "m_mono",
type: "raster",
source: "m_mono",
minzoom: 0,
maxzoom: 18
}]
},
center: [139.7670, 35.6810],
zoom: 13
});
map.on("load", function() {
});
// ズームコントロール
let nc = new mapboxgl.NavigationControl();
map.addControl(nc, 'top-left');
</script>
```