Hi thanks Jackie..
I've resolved this months ago, but thanks a lot anyway!!!
happy new year :)

--- On Fri, 12/26/08, Jackie Ng-2 (via Nabble) 
<[email protected]> wrote:
From: Jackie Ng-2 (via Nabble) <[email protected]>
Subject: Re: Need help in layerdfefinition
To: "lornen" <[email protected]>
Date: Friday, December 26, 2008, 9:37 AM



Try capturing that xml output, save it to a temp file, and validate it against 
the LayerDefinition-1.0.0.xsd schema. Visual Studio (assuming you have it) can 
easily validate the xml for you.


- Jackie



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








            
This email is a reply to your post @ 
http://n2.nabble.com/Need-help-in-layerdfefinition-tp1814847p1814848.html

You can reply by email or by visting the link above.









-- 
View this message in context: 
http://n2.nabble.com/Need-help-in-layerdfefinition-tp1814847p2096880.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to