[mapguide-users] Getting layer properties
Jim O'Leary
joleary.public at gmail.com
Sun Oct 1 15:01:40 EDT 2006
I found a way. It's a bit roundabout. I was hoping for something simpler...
$map = new MgMap();
$map->Open($resourceService, $mapName);
$layerCollection = $map->GetLayers();
$count = $layerCollection->GetCount();
$queryOptions = new MgFeatureQueryOptions();
for($i=0;$i<$count;$i++)
{
$nextLayer = $layerCollection->GetItem($i);
$layerName = $nextLayer->GetName();
$resourceIdentifier = new
MgResourceIdentifier("Library://Cowichan/Data/$layerName.FeatureSource");
$featureReader =
$featureService->SelectFeatures($resourceIdentifier,$layerName,$queryOptions);
/* $arLayerProperties is passed by reference, so we don't have to
return it. We don't
have to declare it ahead of time, either. Thanks, PHP.
*/
getLayerProperties($featureReader,$layerName,$arLayerProperties);
}
// Display our data
print "<pre>";
print_r($arLayerProperties);
print "</pre>";
function getLayerProperties($featureReader,$layerName,&$arLayerProperties)
{
$featureReader->ReadNext();
$propertyCount = $featureReader->GetPropertyCount();
for($i=0; $i<$propertyCount; $i++)
{
$propertyName = $featureReader->GetPropertyName($i);
$boolVal = $featureReader->IsNull($propertyName);
if ($boolVal)
{
continue;
}// end if
$arLayerProperties[$layerName][] = $propertyName;
}// end for
}//end of getLayerProperties
Jim O wrote:
>
> I can open a map and then iterate through the layers like this:
>
> $layerCollection = $map->GetLayers();
> $count = $layerCollection->GetCount();
> for($i=0;$i<$count;$i++)
> {
> $nextLayer = $layerCollection->GetItem($i);
> }
>
> I'd like next to get the properties for each layer, something like:
>
> $propertiesCollection = $nextLayer->GetProperties();
>
> But I don't see any method for that. Is there a way to do it?
>
> Thanks.
>
--
View this message in context: http://www.nabble.com/Getting-layer-properties-tf2365772.html#a6591625
Sent from the OSGeo MapGuide mailing list archive at Nabble.com.
More information about the Mapguide-users
mailing list