Appearance
Bắt đầu nhanh
Đây là demo:
Dưới đây là cách nhúng SDK vào trang web của bạn:
html
<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test VGMMap SDK - Site 2</title>
<style>
body,
html {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
font-family: sans-serif;
}
#map-container {
width: 100vw;
height: 100vh;
background-color: #f0f0f0;
}
#status {
position: absolute;
top: 10px;
left: 10px;
background: rgba(255, 255, 255, 0.9);
padding: 10px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
z-index: 1000;
pointer-events: none;
}
</style>
</head>
<body>
<div id="map-container"></div>
<script>
const statusEl = document.getElementById("status");
const script = document.createElement("script");
script.src = `http://maps.vgm.ai/vgm-sdk/vgmmap-sdk.js`;
script.async = true;
script.onload = () => {
const container = document.getElementById("map-container");
const sdk = new window.VGMMap({
container,
apiBase: "https://maps.vgm.ai/vgm-sdk",
});
sdk.on("APP_READY", () => {
// replace 5 by your site_id
sdk.setSite(5);
});
sdk.on("FLOOR_CHANGED", ({ floor }) => {
});
sdk.init();
};
script.onerror = () => {
console.error("❌ Thất bại khi tải SDK.");
if (statusEl) {
statusEl.innerText = "Lỗi: Không tải được SDK!";
statusEl.style.color = "red";
}
};
document.body.appendChild(script);
</script>
</body>
</html>