[mapguide-users] Re: Add layer from sdf

Zac Spitzer zac.spitzer at gmail.com
Wed Jun 9 04:12:02 EDT 2010


you need to refresh the map via the browser to pick up the changes

On 9 June 2010 18:09, navya024 <navya.gudupi at gmail.com> wrote:
>
> 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.
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>



-- 
Zac Spitzer
Solution Architect / Director
Ennoble Consultancy Australia
http://www.ennoble.com.au
http://zacster.blogspot.com
+61 405 847 168


More information about the mapguide-users mailing list