Creating an HTML Client Application
This sample demonstrates how to incorporate TerraExplorer COM capabilities into a web page using the SGWorld object that gives you access to all of its main interfaces.
<html>
<body onload="Init();">
<script language="javascript">
function Init() {
// To use the latest version of SGWorld
var sgworld = initSGWorld("");
// To use a specific version of SGWorld
// var SGWorld = initSGWorld("3a4f91a0-65a8-11d5-85c1-0001023952c1");
// Safety check: If SGWorld fails to initialize, exit the function
if (sgworld == null) return;
sgworld.Navigate.ZoomIn();
}
function initSGWorld(clsid) {
try {
if (sgworld)
return SGWorld.CreateInstance(clsid);
}
catch (e) { }
// Fusion
if (parent && parent. sgworld) {
return parent.SGWorld.CreateInstance(clsid);
}
// Desktop
try {
// try IE
var obj = document.createElement('object');
obj.setAttribute('id', '__sgworld_ie__');
obj.setAttribute('classid', 'CLSID:3a4f91a0-65a8-11d5-85c1-0001023952c1');
document.body.appendChild(obj);
return __sgworld_ie__.CreateInstance(clsid);
} catch (e) { } //Not IE
try {
// Try Edge
return __sgworld__.CreateInstance(clsid)
} catch (e) { } // Not Edge
return null;
}
</script>
</body>
</html>