I am rather new to Cesium and am trying to get my head around things.
I am trying to create a Javascript file in Eclipse, that will contain certain properties and functions. Id like to be able to create an instance of this Javascript object inside of the "Javascript code" window in Sandcastle running locally.
It is my understanding that the following are essentially the Import/Using statements for Javascript. This was pulled directly from the <head> of the HelloWorld.html example
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../Build/CesiumUnminified/Cesium.js"></script>
<script type="text/javascript" src="../Sandcastle-warn.js"></script>
<script type="text/javascript" src="../../../Source/Test/test.js"></script>
I have created a Test folder and test.js script inside of the Source folder, and have put what I think is the correct statement here in HTML to include this.
test.js looks like this:
/*global define*/
define([ ], function()
{
"use strict";
var test = function test()
{
this.publicMember = "hello";
};
function MyTestFunction()
{
return this.publicMember;
}
});
My problem is that I cant reference this object properly through the "Javascript code" window in SandCastle. Can someone give me a simple example or point me in the right direction?
<script type="text/javascript" src="../test.js"></script>.
I am however still having the same issues.
--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I have tried modifying test.js to be as simple as possible. It now only includes the following function.
function MyTestFunction()
{
}
and HelloWorld.html looks like this.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <!-- Use Chrome Frame in IE -->
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Use the Cesium Widget to start building new applications or easily embed Cesium into existing applications.">
<meta name="cesium-sandcastle-labels" content="Beginner">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../Build/CesiumUnminified/Cesium.js"></script>
<script type="text/javascript" src="../Sandcastle-warn.js"></script>
<script type="text/javascript" src="../test.js"></script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-plain.html" data-sandcastle-title="Cesium (standalone)">
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<script id="cesium_sandcastle_script">
var widget = new Cesium.CesiumWidget('cesiumContainer');
</script>
</body>
</html>
test.js is inside of the SandCastle directory, one up from where HelloWorld.html is included in the SandCastle>Gallery directory.
All i have inside of the "JavaScript code" window in Cesium is
var widget = new Cesium.CesiumWidget('cesiumContainer');
MyTestFunction();
When running this I have been receiving the following errors.
Documentation not available. Please run the 'generateDocumentation' build script to generate Cesium documentation.
Uncaught ReferenceError: MyTestFunction is not defined (on line 3)
Not sure what I am doing wrong here.
Thanks so much for the help Scott! This solved my problem.