CreateRasterLayerDefinitionXml

Land Desktop Map 3D Samples

 
CreateRasterLayerDefinitionXml
 
 
 

This function creates layer definition information for a raster image feature and returns it as a string containing XML data. It takes two parameters: the identifier of the feature source and the string name of the raster feature.

Do the following:

  1. Create an OSGeo.MapGuide.Schema.LayerDefinition.GridColorType object.
  2. Create an OSGeo.MapGuide.Schema.LayerDefinition.GridColorRuleType object. Embed the GridColorType object in the GridColorRuleType object.
  3. Create an OSGeo.MapGuide.Schema.LayerDefinition.GridColorStylizationType object. Embed the GridColorRuleType object in the GridColorStylizationType object.
  4. Create an OSGeo.MapGuide.Schema.LayerDefinition.GridColorRangeType object. Embed the GridColorStylizationType object in the GridColorRangeType object.
  5. Create an OSGeo.MapGuide.Schema.LayerDefinition.GridLayerDefinitionType object. Embed the GridColorRangeType object in the GridLayerDefinitionType object.
  6. Create an OSGeo.MapGuide.Schema.LayerDefinition.LayerDefinitionType object. Embed the GridLayerDefinitionType object in the LayerDefinitionType object.
  7. Serialize the resulting xml LayerDefinitionType object as a string.

Here is an example of a raster layer definition type.

<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n
<LayerDefinitionType xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n 
  <GridLayerDefinition>\r\n
    <ResourceId>Library://Data/Raster/bayarea.FeatureSource</ResourceId>\r\n
    <FeatureName>rasters:bayarea</FeatureName>\r\n 
    <Geometry>Image</Geometry>\r\n
    <GridScaleRange>\r\n
      <ColorStyle>\r\n
        <ColorRule>\r\n
          <LegendLabel />\r\n
          <Color>\r\n
            <Band>1</Band>\r\n 
          </Color>\r\n 
        </ColorRule>\r\n
      </ColorStyle>\r\n
      <RebuildFactor>1</RebuildFactor>\r\n
    </GridScaleRange>\r\n
  </GridLayerDefinition>\r\n
</LayerDefinitionType>