Developer Notes for HelloWorld Example 1 - Embedded Objects |
---|
---------- GENERAL COMMENTS ----------- This section demonstrates how the ActiveX Controls which have been embedded in the web page can be accessed and controlled from Javascript functions. This is a very simple example designed to act as a training tool only. In only works in the IE Browsers (not Netscape/Mozilla) and does not do some of the checking required for a professional and robust public web page. However, you can experiment with this page and learn the key fundamentals that you require to move on to learning how to do an advanced web page incorporating the Earth Resource Mapping layered view control. |
---------- NOTE 1 - ONLOAD EVENTS ----------- <BODY onload="onLoadCB();"> ANALYSIS: Mozilla browsers (including Netscape 7+) do not handle the body onload event reliably, firing the event before our controls are fully loaded. This onload event code in the body tag sets up a call to a handler that puts a .5 second delay in before trying to access the controls on the page to give them time to load. This function sets up the timer: function onLoadCB() { tOnLoadTimer = setTimeout("LoadHandler()", 500); } |
---------- NOTE 2 - toolbar object embedding ----------- <OBJECT classid="clsid:79E46020-ED4B-447A-B191-AD2A63AF51A1" codebase="/ecwplugins/ncs.cab#version=2,0,0,0" id="ECWToolBar1"> <EMBED type="application/x-ImageWebServer-toolbar" name="ECWToolBar1"> </OBJECT> ANALYSIS: - classid is a unique number assigned to a particular ActiveX Control and must be used as shown - id is the name assigned to the control for use in making Javascript calls to the control .. it can be any valid string name - codebase defines a path used for checking that the browser version of the plugin is up to date with the specified version # - EMBED is used if loading the page from a Netscape/Mozilla browser |
---------- NOTE 3 - embedding the layeredview control ----------- <OBJECT classid="clsid:D147430C-86CD-4E6F-A807-93FBC496D201" width=580 height=400 codebase="/ecwplugins/ncs.cab#version=2,0,0,0 " id="ECWView1" > <EMBED type="application/x-ImageWebServer2-ecw" width=580 height=400 name="ECWView1" pluginspage="/ecwplugins/DownloadNetscapePlugin.htm"> </OBJECT> ANALYSIS: - classid is a unique number assigned to a particular ActiveX Control and must be used as shown - width and height can be used to define the size of the map view and may be specified in percent or pixels. - codebase defines a path used for checking that the browser version of the plugin is up to date - id is the name assigned to the control for use in making Javascript calls to the control .. it can be any valid string name - EMBED is the tag used if the page is loaded in a Netscape 7+/Mozilla browser |
---------- NOTE 4 - embedding the
progressbar control ----------- <OBJECT classid='clsid:584719E2-015C-438F-A012-0085270F8E63' codebase='/ecwplugins/ncs.cab#version=2,0,0,0 ' width=580 height=15 id='ECWProgressBar1'> <EMBED type='application/x-ImageWebServer-progressbar' width=580 height=16 id='ECWProgressBar1' name='ECWProgressBar1' pluginspage='/ecwplugins/DownloadNetscapePlugin.htm'> </OBJECT> ANALYSIS: - classid is a unique number assigned to a particular ActiveX Control and must be used as shown - width and height can be used to define the size of the map view and may be specified in percent or pixels. - codebase defines a path used for checking that the browser version of the plugin is up to date. Normally you would not run into this because checking code would have detected the version needed updating before the control was accessed. - id is the name assigned to the control for use in making Javascript calls to the control .. it can be any valid string name - style allows you to put spacing between the progressbar and surrounding objects |
--- NOTE 4a - Version checking ------------ if (parseFloat(navigator.appVersion) < 4.0) { document.location = "/ecwplugins/sorry.htm"; } ANALYSIS: - First we check to see that the Browser version is supported and if too old branch to the 'sorry.htm' page. ECWCheckPlugin(); // call to function in NCSCheck.js Javascript Include File ANALYSIS: This code calls a function in the NCSCheck.js file which goes through a process of checking the Browser type to ensure that a supported browser version is being used. If not, it branches to the Sorry.htm page to advise the user which browsers are supported. If a valid version of browser is being used then the code proceeds to check the version of the ECW Plug-in against the version number embedded in the IMAGE_WEB_SERVER_VERSION constant stored in the NCSConstants.js file. If the current installed version is older than this value, the code will automatically start the upgrade for the plug-in for their browser type. |
---------- NOTE 5 - ----------- function LoadHandler() { if (document.ECWView1.AddLayer("ECW", imageSRC1, "RasterLayer1", "" ) < 0) { alert("Error adding ECW Layer' : \n\n" + document.ECWView1.GetLastErrorText()); }else { // code to attach the toolbar & the progressbar to the layeredview control. document.ECWToolBar1.Attach(document.ECWView1.GetAttachPoint()); document.ECWProgressBar1.Attach(document.ECWView1.GetAttachPoint()); } ANALYSIS: - notice that the code accessed the name of the view control (ECWView1) assigned by the <object></object> tag. - always preface the name of a control with 'document.' to be compatible with Netscape/Mozilla browsers. - .AddLayer is a method used to insert an image into a layer of the control - "ECW" defines the image layer TYPE, in this case streaming Enhanced Compression Wavelet Protocol from an Image Web Server. - imageSRC1 is the image path variable assigned above (This could be hardcoded into the AddLayer as a string as well) - "RasterLayer1" assigns a name to the layer and can be any string value but each layer must be unique. - "" is where you can assign parameters which effect the image view. An example would be "transparency=.5" - Error Handling - the AddLayer method returns -1 if an error is encountered and it is good practise to test for this and alert the error if one occurs by using the method .GetLastErrorText() - Attaching the Toolbar and Progressbar controls to the View Control- in the else branch ... if the AddLayer succeeds then we attach the other two controls, the toolbar and progress bar to the layeredview control. |
---------- NOTE 6 ----------- document.ECWToolBar1.Attach(document.ECWView1.GetAttachPoint()); document.ECWProgressBar1.Attach(document.ECWView1.GetAttachPoint()); ANALYSIS: - This is the old way of attaching toolbar and progressbar objects to the View control. - It is no longer recommended because it does not work reliably in the Mozilla style browsers (including Netscape 7+) or in the Java Applet deployment. - See the next tutorial Hello World using Classes for an example of how it is recommended now. |