[mapguide-users] Re: Add layer from sdf

navya024 navya.gudupi at gmail.com
Wed Jun 9 04:09:47 EDT 2010


Hi sir,
based on your suggestion i wrote the following code to add layer from sdf.


 $resourceID = new MgResourceIdentifier('Library://new/dat.FeatureSource');
 $byteSource = new MgByteSource('E:\data\GFProp_Req.sdf');
 $data = $byteSource->GetReader();
 $resourceService->SetResourceData($resourceID, 'locations of points of
interest', 'File', $data);
  $newLayer=CreatLayer($resourceService,$resourceID,$sessionId);

     ?>
<script language="javascript">
alert("Hi");
</script>
<?php


	$map->GetLayers()->Insert(0, $newLayer);
                $map->Save($resourceService);
 $map->Save($resourceService);

}
catch (MgException $e)
{
  echo "<script language=\"javascript\" type=\"text/javascript\"> \n";
  $message = $e->GetMessage();
  $message = str_replace("\n", " ", $message);
  echo "    alert(\" " . $message . " \"); \n";
  echo "</script> \n";
}




function CreatLayer($resourceService, $bufferFeatureResId, $sessionId)
{
try
{

    $doc = DOMDocument::load('bufferlayerdefinition.xml');
    $featureSourceNode = $doc->getElementsByTagName('ResourceId')->item(0);
    $featureSourceNode->nodeValue = $bufferFeatureResId->ToString();
    $layerDefinition = $doc->saveXML();
    $byteSource = new MgByteSource($layerDefinition,
strlen($layerDefinition));
    $byteSource->SetMimeType(MgMimeType::Xml);
    $tempLayerResId = new MgResourceIdentifier("Session:" . $sessionId .
"//Buffer.LayerDefinition");
    $resourceService->SetResource($tempLayerResId, $byteSource->GetReader(),
null);
    $bufferLayer = new MgLayer($tempLayerResId, $resourceService);
    $bufferLayer->SetName("Buffer");
    $bufferLayer->SetLegendLabel("Buffer");
    $bufferLayer->SetDisplayInLegend(true);
    $bufferLayer->SetSelectable(false);

    return $bufferLayer;
}
      catch (MgException $e)
		{
		       echo '<p>' . $e->GetMessage() . '</p>';
		       echo '<p>' . $e->GetDetails() . '</p>';
    	}
}

but the layer is shown on legend ?but it doesn't show on map?
may i have done any mistakes?Please guide me 
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Add-layer-from-sdf-tp5017702p5157244.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list