function add_layer_to_group($layer, $layerGroupName, $layerGroupLegendLabel, &$map) { // Get the layer group $layerGroupCollection = $map->GetLayerGroups(); if ($layerGroupCollection->Contains($layerGroupName)) { $layerGroup = $layerGroupCollection->GetItem($layerGroupName); } else { // It does not exist, so create it $layerGroup = new MgLayerGroup($layerGroupName); $layerGroup->SetVisible(true); $layerGroup->SetDisplayInLegend(true); $layerGroup->SetLegendLabel($layerGroupLegendLabel); $layerGroupCollection->Add($layerGroup); } // Add the layer to the group $layer->SetGroup($layerGroup); }
function AddGroup($paramSet) { try { $this->CreateMapFromResource($paramSet); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet={$paramSet} AND ParamName=\"GROUPNAME\""); $groupName = $this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet={$paramSet} AND ParamName=\"PARENTGROUPNAME\""); $parentGroupName = $this->unitTestParamVm->GetString("ParamValue"); $groups = $this->map->GetLayerGroups(); $group = new MgLayerGroup($groupName); if ($parentGroupName != "") { $parentGroup = $group->SetGroup($groups->GetItem($parentGroupName)); $group->SetGroup($parentGroup); } $groups->Add($group); return new Result($groups->GetCount(), "text/plain"); } catch (MgException $e) { return new Result(get_class($e), "text/plain"); } }
function OpenMarkup() { $resourceService = $this->site->CreateService(MgServiceType::ResourceService); $map = new MgMap(); $map->Open($resourceService, $this->args['MAPNAME']); // Create the Layer Groups $markupGroup = null; $layerGroups = $map->GetLayerGroups(); if ($layerGroups->Contains('_Markup')) { $markupGroup = $layerGroups->GetItem('_Markup'); } else { $markupGroup = new MgLayerGroup('_Markup'); $markupGroup->SetVisible(true); $markupGroup->SetLegendLabel('Markup'); $markupGroup->SetDisplayInLegend(true); $layerGroups->Add($markupGroup); } // Add the Markup Layer $markupLayerResId = new MgResourceIdentifier($this->args['MARKUPLAYER']); $markupLayer = new MgLayer($markupLayerResId, $resourceService); $markupLayer->SetName('_' . $markupLayerResId->GetName()); $markupLayer->SetLegendLabel($markupLayerResId->GetName()); $markupLayer->SetDisplayInLegend(true); $markupLayer->SetSelectable(true); $markupLayer->SetGroup($markupGroup); $map->GetLayers()->Insert(0, $markupLayer); $map->Save($resourceService); }