GeoMOOSE User Extensions are the latest way to customize a GeoMOOSE installation. While it has been common practice to modify the root of the code to create various custom tools, that has left some installations stagnant and unable to smoothly upgrade or integrate with new GeoMOOSE releases when they have become available. To address these concerns, we have developed GeoMOOSE User Extensions. These extensions will never be clobbered by a GeoMOOSE upgrade. However, extensions written that access core library functions may break as the underlying library API’s may change over time.
The purpose of user extensions is for the customizer of a site to, “go crazy.” It allows for users to add any functionality they wish to the user interface without forcing their code to break away from the main code base.
Good Question. Here is a brief tutorial...
Say you want a disclaimer to show at the beginning of the application. Let’s just say that disclaimer is, “Hello, World!”
User extensions are stored in the “extensions/” folder under “htdocs/”. For this example we’ll create a file called, “Disclaimer.js”. In “Disclaimer.js” we need to add the basic outline of the class by inhereting from the base user extension class. The file should look like this:
DisclaimerExtension = new OpenLayers.Class(GeoMOOSE.UX.Extension, {
CLASS_NAME : "DisclaimerExtension"
});
Now we need to have the class actually do something. The initial function that is called when an extension is loaded is called “load.” So, now we define the load method andh have it display our disclaimer using “alert.”
DisclaimerExtension = new OpenLayers.Class(GeoMOOSE.UX.Extension, {
load: function() {
alert("Hello, World!");
},
CLASS_NAME: "DisclaimerExtension"
});
Finally, we need to tell GeoMOOSE to load the extension at startup by adding this at the end of the file:
GeoMOOSE.UX.register('DisclaimerExtension');
The completed “Disclaimer.js” should look like this:
DisclaimerExtension = new OpenLayers.Class(GeoMOOSE.UX.Extension, {
load: function() {
alert("Hello, World!");
},
CLASS_NAME: "DisclaimerExtension"
});
GeoMOOSE.UX.register('DisclaimerExtension');
Open “geomoose.html” in a text editor.
Find “</head>”
On the directly above “</head>” add:
<script type="text/javascript" src="extensions/Disclaimer.js"></script>
Now you should see “Hello, World!” when the application starts.
An example of an User Extension which updates the interface on a periodic basis can be found in the “extensions/” directory with GeoMOOSE 2.2, the file is called “ColorChanger.js”.