Last active
December 15, 2017 05:34
-
-
Save yozaw/c62490ceed9c8d3b81693bee4cd44d2b to your computer and use it in GitHub Desktop.
Monaca のサンプル コード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require([ | |
"esri/WebMap", | |
"esri/views/MapView", | |
"dojo/domReady!" | |
], function(WebMap, MapView) { | |
var map = new WebMap({ | |
portalItem: { | |
id: "33b1033fe2d5415482f8d72d939978ec" // Web マップのアイテム ID を指定 | |
} | |
}); | |
var view = new MapView({ | |
container: "viewDiv", // ビューを表示する DOM ノードへの参照 | |
map: map // 「マップの作成」のステップで作成した WebMap オブジェクト | |
}); | |
ons.ready(function() { | |
document.addEventListener('postchange', function (event) { | |
if (event.index === 0) { | |
map.basemap = "streets" // 背景地図を道路地図に変更 | |
} else if (event.index === 1) { | |
map.basemap = "satellite" // 背景地図を衛星画像に変更 | |
} else { | |
map.basemap = "osm" // 背景地図をオープンストリートマップに変更 | |
} | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | |
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'"> | |
<script src="components/loader.js"></script> | |
<script src="lib/onsenui/js/onsenui.min.js"></script> | |
<link rel="stylesheet" href="components/loader.css"> | |
<link rel="stylesheet" href="lib/onsenui/css/onsenui.css"> | |
<link rel="stylesheet" href="lib/onsenui/css/onsen-css-components.css"> | |
<link rel="stylesheet" href="css/style.css"> | |
<link rel="stylesheet" href="https://js.arcgis.com/4.4/esri/css/main.css"> | |
<script src="https://js.arcgis.com/4.4/"></script> | |
<script type="text/javascript" src="app.js"></script> | |
<script> | |
ons.ready(function() { | |
console.log("Onsen UI is ready!"); | |
}); | |
</script> | |
</head> | |
<body> | |
<ons-page> | |
<ons-toolbar> | |
<div class="center"> | |
<ons-segment id="segment" style="width: 220px"> | |
<button>道路地図</button> | |
<button>衛星画像</button> | |
<button>OSM</button> | |
</ons-segment> | |
</div> | |
</ons-toolbar> | |
<div id="viewDiv"></div> | |
</ons-page> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#viewDiv { | |
padding: 0; | |
margin: 0; | |
height: 100%; | |
width: 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment