[mapguide-users] Need help in layerdfefinition

padmini godavarthi godavarthi.padmini at gmail.com
Thu Jan 1 06:56:54 EST 2009


Hi,
iam using mapguide opensource2.0 (with.net 2.0 +IIS 5.1)

>From ur code 

1)How can i get    LayerDefinitionFactory ?
2)its not available for me.
Can u plz send me the code.



Thanks and Regards,
Padmini.


lornen wrote:
> 
> Hi,
> 
> This is my first time using MapGuide Enterprise, and I would appreciate
> some help. 
> I am getting a XML Parser exception when I tried to SetResource at the
> last line of the code.
> 
>  CODE:
>         private void CreateMarkupLayer()
>         {
>             string markupName = "redline";
>             MgSiteConnection site = getSite();
>             MgResourceService resourceService =
> (MgResourceService)site.CreateService(MgServiceType.ResourceService);
>             MgFeatureService featureService = (MgFeatureService)
> site.CreateService(MgServiceType.FeatureService);
>             // Create the Markup Feature Source (SDF)
> 
>             MgResourceIdentifier markupID = new
> MgResourceIdentifier("Library://Markup/" + markupName + ".FeatureSource");
>             MgFeatureSchema markupSchema =
> MarkupSchemaFactory.CreateMarkupSchema();
>             MgCreateSdfParams sdfParams = new MgCreateSdfParams("LL84",
> LL84WKT, markupSchema);
>             featureService.CreateFeatureSource(markupID, sdfParams);
> 
>             LayerDefinitionFactory factory = new LayerDefinitionFactory();
>             // Create a line rule.
>             string legendLabel = "";
>             string filter = "";
>             string color = "FF0000FF";
>             string lineRule =
> factory.CreateLineRule(legendLabel,filter,color);
>             // Create a line type style.
>             string lineTypeStyle = factory.CreateLineTypeStyle(lineRule);
>             // Create a scale range.
>             string minScale = "0";
>             string maxScale = "1000000000000";
>             string lineScaleRange = factory.CreateScaleRange(minScale,
> maxScale, lineTypeStyle);
>             // Create the layer definiton.
>             string featureClass = "Library://Markup/" + markupName +
> ".FeatureSource";
>             string featureName = "MarkupSchema:Markup";
>             string geometry = "SHPGEOM";
>             string layerDefinition =
> factory.CreateLayerDefinition(featureClass,
> featureName,geometry,lineScaleRange);
>             XmlDocument doc = new XmlDocument();
>             doc.LoadXml(layerDefinition);
>             System.Text.UTF8Encoding utf = new System.Text.UTF8Encoding();
>             byte[] BytelayerDefinition = utf.GetBytes(layerDefinition);
>             MgByteSource byteSource = new
> MgByteSource(BytelayerDefinition, BytelayerDefinition.Length);
>             byteSource.SetMimeType(MgMimeType.Xml);
>             resourceService.SetResource(markupID, byteSource.GetReader(),
> null);
>         }
> 
> 
> The string layerDefinition which i got from
> factory.CreateLayerDefinition() is as follows:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <LayerDefinition version="1.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="LayerDefinition-1.0.0.xsd">
>     <VectorLayerDefinition>
>       <ResourceId>Library://Markup/redline.FeatureSource</ResourceId>
>       <FeatureName>MarkupSchema:Markup</FeatureName>
>       <FeatureNameType>FeatureClass</FeatureNameType>
>       <Geometry>SHPGEOM</Geometry>
>       <VectorScaleRange>
>         <MinScale>0</MinScale>
>         <MaxScale>1000000000000</MaxScale>
>         <LineTypeStyle>
>           <LineRule>
>             <LegendLabel></LegendLabel>
>             <Filter></Filter>
>             <LineSymbolization2D>              
>               <LineStyle>Solid</LineStyle>
>               <Thickness>1</Thickness>
>               <Color>FF0000FF</Color>
>               <Unit>Points</Unit>
>             </LineSymbolization2D>
>           </LineRule>
>         </LineTypeStyle>
>       </VectorScaleRange>
>     </VectorLayerDefinition>
>   </LayerDefinition>
> 
> 
> I'm using asp.net, c# and MapGuide Enterprise 2007
> 
> Thanks
> 

-- 
View this message in context: http://n2.nabble.com/Need-help-in-layerdfefinition-tp1814847p2098593.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list