3D建築材質控制器
此範例示範如何加入建築材質控制器,包含以下功能:
- 加入材質控制器:於
style.load後新增TextureControl,並置於地圖右上角
info
詳細使用說明請參考「TextureControl」。
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>3D建築材質控制器</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://kw3dmap.localking.com.tw/openapi/loader/mapPlus-1.3.9.loader.js" crossorigin="anonymous" referrerpolicy="origin"></script>
<style>
body { margin: 0; padding: 0; }
#map { width: 100vw; height: 100vh; }
</style>
</head>
<body>
<div id="map"></div>
<script type="module">
const map = await new mapPlus(document.getElementById("map"), {
accessKey: 'get_your_key', // 聯絡勤崴國際,取得專屬key
accessToken: 'get_your_token', // 聯絡勤崴國際,取得專屬token
style: 'https://kw3dmap.localking.com.tw/openapi/map/kwmap.etxt',
center: [121.54974027843537, 25.03772631201406],
zoom: 18,
maxZoom: 20.99,
minZoom: 7,
pitch: 30,
bearing: -100,
});
/* ══════════════════════════════════════════════════════════════════════════
* 加入材質控制器:
- 可調整 useButton,顯示/隱藏預設按鈕。
- 可調整 ignoreLandmark,忽略特殊地標套用建物材質。
══════════════════════════════════════════════════════════════════════════ */
map.on("style.load", () => {
const textureCtrl = new mapPlus.TextureControl({
// 是否使用按鈕控制建物材質的開關
useButton: true,
// 如果圖磚為特殊地標,是否要忽略套用建物材質
ignoreLandmark: false,
});
map.addControl(textureCtrl, "top-right");
});
</script>
</body>
</html>
<script src="https://kw3dmap.localking.com.tw/openapi/loader/mapPlus-1.3.9.loader.js" crossorigin="anonymous" referrerpolicy="origin"></script>
<script type="module">
const map = await new mapPlus(document.getElementById("map"), {
accessKey: 'get_your_key', // 聯絡勤崴國際,取得專屬key
accessToken: 'get_your_token', // 聯絡勤崴國際,取得專屬token
style: 'https://kw3dmap.localking.com.tw/openapi/map/kwmap.etxt',
center: [121.54974027843537, 25.03772631201406],
zoom: 18,
maxZoom: 20.99,
minZoom: 7,
pitch: 30,
bearing: -100,
});
/* ══════════════════════════════════════════════════════════════════════════
* 加入材質控制器:
- 可調整 useButton,顯示/隱藏預設按鈕。
- 可調整 ignoreLandmark,忽略特殊地標套用建物材質。
══════════════════════════════════════════════════════════════════════════ */
map.on("style.load", () => {
const textureCtrl = new mapPlus.TextureControl({
// 是否使用按鈕控制建物材質的開關
useButton: true,
// 如果圖磚為特殊地標,是否要忽略套用建物材質
ignoreLandmark: false,
});
map.addControl(textureCtrl, "top-right");
});
</script>
<style>
body { margin: 0; padding: 0; }
#map { width: 100vw; height: 100vh; }
</style>