[mapguide-users] Dynamically creating a line layer with SDF Feature Source

uXuf yousuf.hassan at gmail.com
Wed Nov 28 18:25:44 EST 2007


Hi all,

I am trying to add a layer of lines to my map using an existing
FeatureSource in the library. This FeatureSource was generated from an SDF
(created by Map 3D). I want to create the layer using the
LayerDefinitionFactory instead of the usual XML file way. 

However, I get a "The new XML document is invalid" error when I try to use
the add_layer_definition_to_map() function of the
LayerDefinitionFactory.php. Inspecting this problem it turns out that the
layer definition that (I think) I am sending with the code is failing to
validate with the LayerDefinition-1.0.0.xsd. I haven't touched the XSD file
at all since installation. Probably this error could lie when I am creating
my geometry, I checked in the examples and consistently it was specified as
"SHPGEOM", however when I check it out in Studio by creating a temporary
layer from the feature source it is specified as "Data". I have also checked
by specifying geometry as "Data". The error remains so.

Another thing I am getting confused in is to provide the Feature Name. I
provide it with the value of "SDF_2_Schema:Selected", but I am not sure
whether I should use "SHP_Schema:Selected". Any pointers in this regard
would be greatly welcomed.

Here is the relevant part of my code:

//Set up a temporary layer
$factory = new LayerDefinitionFactory();
$legendLabel = '';
$filter = '';
$color = 'FF0000FF';
$lineRule = $factory->CreateLineRule($legendLabel, $filter, $color);
$lineTypeStyle = $factory->CreateLineTypeStyle($lineRule);
$minScale = '0';
$maxScale = '1000000';
$lineScaleRange = $factory->CreateScaleRange($minScale, $maxScale,
$lineTypeStyle);

//The following FeatureSource is generated from and SDF
$featureClass = "Library://akMaps/Data/Arteries.FeatureSource";

//Could this be the real culprit?
$featureName = "SDF_2_Schema:Selected";

//Or this?
$geometry = 'Data';
$layerDefinition = $factory->CreateLayerDefinition($featureClass,
$featureName, $geometry, $lineScaleRange);

//error occurs in this function, fails to validate with LayerDefinition.xsd
$newLayer = add_layer_definition_to_map($layerDefinition, "Selected",
"Selected", $mgSessionID, $resourceService, $map);


Any help would be greatly appreciated.

Thanks in advance,
uXuf

-- 
View this message in context: http://www.nabble.com/Dynamically-creating-a-line-layer-with-SDF-Feature-Source-tf4893966s16610.html#a14015641
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list