blog/content/posts/2019/002-setup-dev-environment.md

67 lines
2.0 KiB
Markdown
Raw Normal View History

+++
title = "JavaScriptではじめるWebマップアプリケーション: Chapter2-1"
date = 2019-05-01T19:06:46+08:00
2021-02-20 13:15:18 +00:00
description = "JavaScriptではじめるWebマップアプリケーションの内容を淡々と試してみます。"
2021-11-17 13:56:35 +00:00
categories = ["Map"]
2021-02-23 13:15:28 +00:00
author = "kazu634"
2022-08-21 08:25:55 +00:00
images = ["ogp/002-setup-dev-environment.webp"]
2021-02-27 12:05:32 +00:00
tags = ["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>
```