|
|
Server-side XML
What you need first of all, is a new directory, under the "applications" directory, with the name of your new application. Then in this newly created directory, you will need configuration files, such as the ones described in the Configuration manual.
application.xml : The application definitionEvery geomajas application configuration starts with the application.xml file. This file contains references to other XML files that are part of the configuration, and also contains a list of all "LayerModelFactories". A layermodelfactory is a factory for creating layerModels. It is basically a source of data. geomajas supports LayerModelFactories for vector layers, and for raster layers. In the helloworld application, we only use rasters for simplicity. Exert from application.xml: <url>helloworld</url>
<name>hello world application</name>
<rasterLayerFactory id="osm">
<factoryClass>OSMLayerFactory</factoryClass>
<parameterMap />
</rasterLayerFactory>
The first tag defines the location of the application configuration. You may have noticed that the entire helloworld application (both XML's and HTML's) is located in a directory called "helloworld", AND that in the onLoad event in the HTML page, we used "helloworld" as "globals["applicationUrl"]". This is no coincidence. This is how the client-side is able to retrieve the configuration for this application.
maps.xml : Application map definitionsThe maps.xml contains the configurations of all maps that are needed in an application. We previously saw that the body tag of our HTML page contains a MapWidget with the name "helloMap". In this map.xml configuration file, we will now define this map: <map id="helloMap">
<backgroundColor>#E0E0E0</backgroundColor>
<lineSelectStyle>
<fillOpacity>0</fillOpacity>
<strokeColor>#FF6600</strokeColor>
<strokeOpacity>1</strokeOpacity>
</lineSelectStyle>
<pointSelectStyle>
</pointSelectStyle>
<polygonSelectStyle>
<fillColor>#FFFF00</fillColor>
<fillOpacity>0.5</fillOpacity>
</polygonSelectStyle>
<crs>EPSG:900913</crs>
<scaleBarEnabled>false</scaleBarEnabled>
<panButtonsEnabled>true</panButtonsEnabled>
<overview />
<maximumScale>50</maximumScale>
<initialBounds x="1272591" y="-4479530" width="2247855" height="1423560" />
<layerConfig>
<xi:include href="layers/osm.xml" />
<mapOrder>
<layerRef>osm</layerRef>
</mapOrder>
<layerTree>
<label>Layers</label>
<layerRef>osm</layerRef>
</layerTree>
</layerConfig>
</map>
Again, for a complete manual on how to configure a map in geomajas, seek out the geomajas configuration manual.
osm.xml : An Open Street Maps raster layerThis is the configuration file for the only layer in the helloworld application: An Open Street Maps raster layer. <layer xmlns="http://geomajas.org/schemas/configuration/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="osm"
xsi:type="rasterLayerInfo">
<label>OpenStreetMap</label>
<visible>true</visible>
<layerType>1</layerType>
<crs>EPSG:900913</crs>
<viewScale>
<min>0</min>
<max>50</max>
</viewScale>
<maxExtent>
<minX>-20037508.34</minX>
<maxX>20037508.34</maxX>
<minY>-20037508.34</minY>
<maxY>20037508.34</maxY>
</maxExtent>
<maxTileLevel>16</maxTileLevel>
<rasterLayerFactoryRef>osm</rasterLayerFactoryRef>
<layerName></layerName>
<tileWidth>256</tileWidth>
<tileHeight>256</tileHeight>
<style>1</style>
<resolutions>
<resolution>156543.03</resolution>
<resolution>78271.52</resolution>
<resolution>39135.76</resolution>
<resolution>19567.88</resolution>
<resolution>9783.94</resolution>
<resolution>4891.97</resolution>
<resolution>2445.98</resolution>
<resolution>1222.99</resolution>
<resolution>611.49</resolution>
<resolution>305.75</resolution>
<resolution>152.874057</resolution>
<resolution>76.4370283</resolution>
<resolution>38.2185141</resolution>
<resolution>19.1092571</resolution>
<resolution>9.55462853</resolution>
<resolution>4.77731427</resolution>
<resolution>2.38865713</resolution>
<resolution>1.19432857</resolution>
</resolutions>
</layer>
This is the configuration of a layer named "osm" (see the ID attribute in the <layer>-tag). The most important element for now is the "rasterLayerFactoryRef", which points to the RasterLayerFactory we defined in application.xml. LayerType = 1, means that it's a raster layer. These type definitions can be found in the geomajas configuration schema definitions.
|



