VectorLayer Example

 

Let us now throw everything together, and create an example vector layer configuration:

<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="countries"
    xsi:type="vectorLayerInfo">

    <label>Countries of Africa</label>
    <visible>true</visible>
    <layerType>7</layerType>
    <crs>EPSG:4326</crs>
    <viewScale>
        <min>0</min>
        <max>100000</max>
    </viewScale>
    <maxExtent>
        <minX>-85.05112877980659</minX>
        <maxX>85.05112877980659</maxX>
        <minY>-85.05112877980659</minY>
        <maxY>85.05112877980659</maxY>
    </maxExtent>
    <maxTileLevel>16</maxTileLevel>

    <layerDefinition>
        <layerFactory>org.geomajas.core.application.DefaultLayerFactory</layerFactory>
        <label>
            <labelAttribute>CNTRY_NAME</labelAttribute>
        </label>
        <filter  />
        <editPermissions>
            <creatingAllowed>false</creatingAllowed>
            <updatingAllowed>true</updatingAllowed>
            <deletingAllowed>false</deletingAllowed>
        </editPermissions>

        <featureType>
            <layerModelFactoryRef>africaCountryShape</layerModelFactoryRef>
            <name>country</name>
            <identifier>
                <label>Id</label>
                <name>ID</name>
                <type>long</type>
            </identifier>
            <geometryType>
                <name>the_geom</name>
                <crs>EPSG:4326</crs>
                <editable>false</editable>
            </geometryType>            
            <attributes>
                <attribute>
                    <label>Name</label>
                    <name>CNTRY_NAME</name>
                    <editable>true</editable>
                    <identifying>true</identifying>
                    <type>string</type>
                </attribute>
                <attribute>
                    <label>Label</label>
                    <name>COUNTRY</name>
                    <editable>false</editable>
                    <identifying>true</identifying>
                    <type>string</type>
                </attribute>
                <attribute>
                    <label>Region</label>
                    <name>REGION</name>
                    <editable>false</editable>
                    <identifying>true</identifying>
                    <type>string</type>
                </attribute>
                <attribute>
                    <label>OPEC</label>
                    <name>OPEC</name>
                    <editable>true</editable>
                    <identifying>true</identifying>
                    <type>integer</type>
                    <validator>
                        <constraints>{min:0, max:1}</constraints>
                        <required>true</required>
                        <promptMessage>Member of OPEC?</promptMessage>
                        <invalidMessage>Invalid value</invalidMessage>
                        <rangeMessage>Out of range</rangeMessage>
                    </validator>
                </attribute>
                <attribute>
                    <label>UNESCO</label>
                    <name>UNESCO</name>
                    <editable>true</editable>
                    <identifying>true</identifying>
                    <type>integer</type>
                    <validator>
                        <constraints>{min:0, max:1}</constraints>
                        <required>true</required>
                        <promptMessage>Member of UNESCO?</promptMessage>
                        <invalidMessage>Invalid value</invalidMessage>
                        <rangeMessage>Out of range</rangeMessage>
                    </validator>
                </attribute>
            </attributes>
        </featureType>

        <snappingRules>
        </snappingRules>

        <styleDefs>
            <styleDef id="1">
                <name>OPEC and UNESCO Member</name>
                <formula>((OPEC == 1) AND (UNESCO == 1))</formula>
                <style>
                    <fillColor>#336633</fillColor>
                    <fillOpacity>0.7</fillOpacity>
                    <strokeColor>#333333</strokeColor>
                    <strokeOpacity>1</strokeOpacity>
                    <strokeWidth>1</strokeWidth>
                </style>
            </styleDef>
            <styleDef id="2">
                <name>OPEC Member</name>
                <formula>(OPEC == 1)</formula>
                <style>
                    <fillColor>#339933</fillColor>
                    <fillOpacity>0.7</fillOpacity>
                    <strokeColor>#333333</strokeColor>
                    <strokeOpacity>1</strokeOpacity>
                    <strokeWidth>1</strokeWidth>
                </style>
            </styleDef>
            <styleDef id="3">
                <name>UNESCO Member</name>
                <formula>(UNESCO == 1)</formula>
                <style>
                    <fillColor>#33CC33</fillColor>
                    <fillOpacity>0.7</fillOpacity>
                    <strokeColor>#333333</strokeColor>
                    <strokeOpacity>1</strokeOpacity>
                    <strokeWidth>1</strokeWidth>
                </style>
            </styleDef>
            <styleDef id="4">
                <name>The rest</name>
                <formula  />
                <style>
                    <fillColor>#66FF66</fillColor>
                    <fillOpacity>0.7</fillOpacity>
                    <strokeColor>#333333</strokeColor>
                    <strokeOpacity>1</strokeOpacity>
                    <strokeWidth>1</strokeWidth>
                </style>
            </styleDef>
        </styleDefs>
    </layerDefinition>
</layer>