Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create Layers Programmatically

1 REPLY 1
Reply
Message 1 of 2
dhinkle
804 Views, 1 Reply

Create Layers Programmatically

I am having an issue creating a layer programmatically using the MapGuide API (PHP). Here is what I am trying to do:

From an existing feature source and existing layer I want to programmatically create a new layer based on a specific query in the feature source. What is the best way to go about this? Should I use LayerDefinitionFactory to create a new layer or can I copy the existing layer and modify it's definition? I'd also like to display this new layer in the legend - I have seen the example code on how to do this but I need to first get past the layer creation bit.

I have tried using the LayerDefinitionFactory approach but I am getting an empty LayerDefinition. Here is my code:

...

$site = new MgSiteConnection();
$site->Open(new MgUserInformation($args['SESSION']));
$resourceService = $site->CreateService(MgServiceType::ResourceService);
$featureService = $site->CreateService(MgServiceType::FeatureService);
$map = new MgMap($site);
$map->Open($args['MAPNAME']);

$factory = new LayerDefinitionFactory();
$areaRule = $factory->CreateAreaRule('1 to 300000','SQFT >= 1600','FFFFFF00');
$areaTypeStyle = $factory->CreateAreaTypeStyle($areaRule);
$minScale = '0';
$maxScale = '1000000000000';
$areaScaleRange = $factory->CreateScaleRange($minScale, $maxScale, $areaTypeStyle);
$featureClass = 'Library://Data/test2.FeatureSource'; // <-- This is the existing feature source
$featureName = "SDF_2_Schema:test';
$geometry = 'Data';

$layerDefinition = $factory->CreateLayerDefinition($featureClass, $featureName, $geometry, $areaScaleRange);

...

// At this point the layerDefinition is empty so when I try to execute "add_layer_definition_to_map(...)" it fails with an XML parsing error.

Thanks
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: dhinkle

On 22/01/2010 8:27 AM, dhinkle@cisco.com wrote:
> // At this point the layerDefinition is empty so when I try to execute "add_layer_definition_to_map(...)" it fails with an XML parsing error.

Have you tried wrapping this in a try/catch block to see if there is an
exception thrown at some point?

Jason

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report