[mapguide-users] Adding a temporary Layer in MapGuide

Carmelo Saffioti csaffi at libero.it
Wed Jan 21 05:45:03 EST 2009


As I said on my last post, I successfully linked the buffer code to the Task 
Panel item. But there is a problem, when the buffer code is executed I get 
this runtime error:

Buffer Error
An unclassified exception occurred. Exception occurred in method 
new_MgSelection__SWIG_1 at line 649 in file .\MgApi_wrap.cpp

I followed these steps to link the buffer code to the Task Panel:
- In DevGuideSamples\JAVASAMPLES\HELLO_MAP there are TASK_PANE.JSP and 
DISPLAY_SPATIAL_REFERENCE.JSP.
TASK_PANE.JSP is linked to the Task Panel, and it calls 
DISPLAY_SPATIAL_REFERENCE.JSP
- In mapviewerjava there is buffer.jsp
- I copied the buffer.jsp code into the DISPLAY_SPATIAL_REFERENCE.JSP file


How can I solve that problem?

You said to insert points instead of the buffer feature. How? Points (or a 
line in a similar task) have coordinates stored on a MySql database...


----- Original Message ----- 
From: "Kenneth Skovhede, GEOGRAF A/S" <ks at geograf.dk>
To: "MapGuide Users Mail List" <mapguide-users at lists.osgeo.org>
Sent: Wednesday, January 21, 2009 11:24 AM
Subject: Re: [mapguide-users] Adding a temporary Layer in MapGuide


> Yes, just insert points instead of the buffer feature.
>
> Regards, Kenneth Skovhede, GEOGRAF A/S
>
>
>
> Carmelo Saffioti skrev:
>> Thank you for your reply Kenneth.
>> Trying examples on DevGuideSamples I discovered how to work with the Task 
>> Pane...
>>
>> Now I need to draw dynamically on the map points of known x,y 
>> coordinates, after clicking on the appropriate Task item. I hope this can 
>> be done with the buffer script you suggested me. Isn't it?
>>
>>
>> Cheers
>> Carmelo
>>
>>
>> ----- Original Message ----- From: "Kenneth Skovhede, GEOGRAF A/S" 
>> <ks at geograf.dk>
>> To: "MapGuide Users Mail List" <mapguide-users at lists.osgeo.org>
>> Sent: Wednesday, January 21, 2009 9:04 AM
>> Subject: Re: [mapguide-users] Adding a temporary Layer in MapGuide
>>
>>
>>> I have not used the AJAX viewer enough to know how to do this with 
>>> tasks.
>>> The values can be read from the viewer through some property functions:
>>>
>>> http://mapguide.osgeo.org/files/mapguide/docs/2.0/viewerapi.html#mapframe_getsessionid
>>> http://mapguide.osgeo.org/files/mapguide/docs/2.0/viewerapi.html#mapframe_getmapname
>>>
>>> With those, you can manually pass them to the request, if you use the 
>>> "InvokeScript" method,
>>> but there may be an easier way.
>>>
>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>
>>>
>>>
>>> Carmelo Saffioti skrev:
>>>> Thank you for your help!
>>>> I'm seeing that the code you posted is very similar to the buffer code, 
>>>> however I'm really new to MapGuide, so I hope you can help me 
>>>> understanding how to make it work.
>>>>
>>>> I created a Layout, using MapGuide Studio, on which I added a new 
>>>> custom command for the Task panel, named "Route tracing". Therefore I 
>>>> created the route_tracing.jsp file, on which I'm trying to use your 
>>>> code (translating it from PHP to JSP) or the buffer.jsp code (which is 
>>>> already in JSP).
>>>>
>>>> On both your code and buffer.jsp there is this code:
>>>> mapName = GetParameter(request, "MAPNAME");
>>>> sessionId = GetParameter(request, "SESSION");
>>>>
>>>> - The question is: how can I pass the MAPNAME and SESSION values to the 
>>>> web page?
>>>>
>>>> The final result should be a web page, which opens when its Action Task 
>>>> item is clicked, on which I can select and digit some options. After 
>>>> clicking a button the page should get these values, and display the map 
>>>> with the calculated additional layer on it.
>>>>
>>>>
>>>>
>>>> I hope you can help me about that
>>>> Cheers
>>>> Carmelo
>>>>
>>>>
>>>>
>>>> ----- Original Message ----- From: "Arnaud De Groof" 
>>>> <Arnaud.DeGroof at spacebel.be>
>>>> To: "MapGuide Users Mail List" <mapguide-users at lists.osgeo.org>
>>>> Sent: Monday, January 12, 2009 4:18 PM
>>>> Subject: RE: [mapguide-users] Adding a temporary Layer in MapGuide
>>>>
>>>>
>>>> The first code :
>>>> <?php
>>>>
>>>> // Vital includes.
>>>>
>>>> include "../../mapviewerphp/constants.php";
>>>>
>>>> include "../../mapviewerphp/common.php";
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> $args = ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET;
>>>>
>>>> $sessionId = $args['SESSION'];
>>>>
>>>> $mapName = $args['MAPNAME'];
>>>>
>>>> $layerName1 = 'YYY';
>>>>
>>>> $rlLayerResourceId = "Library://XXX/$layerName1.LayerDefinition";
>>>>
>>>>
>>>>
>>>> InitializeWebTier();
>>>>
>>>>
>>>>
>>>> $userInfo = new MgUserInformation($sessionId);
>>>>
>>>> $siteConnection = new MgSiteConnection();
>>>>
>>>> $siteConnection->Open($userInfo);
>>>>
>>>> $resourceService =
>>>> $siteConnection->CreateService(MgServiceType::ResourceService);
>>>>
>>>>
>>>>
>>>> // Read the MapDefinition into an XML DOM document object.
>>>>
>>>> $md = " Library://XXX/$mapName.MapDefinition "; // TODO Constant!
>>>>
>>>> $mdResourceId = new MgResourceIdentifier($md);
>>>>
>>>> $mdReader = $resourceService->GetResourceContent($mdResourceId);
>>>>
>>>> $mdXml = $mdReader->ToString();
>>>>
>>>> $mdDomDoc = DOMDocument::loadXML($mdXml);
>>>>
>>>>
>>>>
>>>> // Add a new MapLayer
>>>>
>>>> $targetNode = $mdDomDoc->getElementsByTagName("MapLayer")->item(0);
>>>>
>>>> $newNode = $targetNode->parentNode->insertBefore(new
>>>> DOMElement("MapLayer"), $targetNode);
>>>>
>>>> $newNode->appendChild($mdDomDoc->createElement("Name", $layerName1));
>>>>
>>>> $newNode->appendChild($mdDomDoc->createElement("ResourceId",
>>>> $rlLayerResourceId));
>>>>
>>>> $newNode->appendChild($mdDomDoc->createElement("Selectable", "false"));
>>>>
>>>> $newNode->appendChild($mdDomDoc->createElement("ShowInLegend",
>>>> "false"));
>>>>
>>>> $newNode->appendChild($mdDomDoc->createElement("LegendLabel"));
>>>>
>>>> $newNode->appendChild($mdDomDoc->createElement("ExpandInLegend",
>>>> "false"));
>>>>
>>>> $newNode->appendChild($mdDomDoc->createElement("Visible", "true"));
>>>>
>>>> $newNode->appendChild($mdDomDoc->createElement("Group"));
>>>>
>>>>
>>>>
>>>> // Save the updated MapDefinition
>>>>
>>>> $updatedXml = $mdDomDoc->saveXML();
>>>>
>>>> $byteSource = new MgByteSource($updatedXml, strlen($updatedXml));
>>>>
>>>>
>>>>
>>>> // Create the temporary MapDefinition
>>>>
>>>> $sessionMapName = $mdResourceId->GetName();
>>>>
>>>> $sessionMapDefinition =
>>>> "Session:$sessionId//$sessionMapName.MapDefinition";
>>>>
>>>> $sessionResourceId = new MgResourceIdentifier($sessionMapDefinition);
>>>>
>>>>
>>>>
>>>> // Write the updated MapDefinition
>>>>
>>>> $resourceService->SetResource($sessionResourceId,
>>>> $byteSource->GetReader(), null);
>>>>
>>>>
>>>>
>>>> //Test the updated MapDefinition
>>>>
>>>> $md1 = "Session:$sessionId//X.MapDefinition";
>>>>
>>>> $mdResourceId2 = new MgResourceIdentifier($md1);
>>>>
>>>> $mdReader2 = $resourceService->GetResourceContent($mdResourceId2);
>>>>
>>>> $mdXml2 = $mdReader2->ToString();
>>>>
>>>> $mdDomDoc2 = DOMDocument::loadXML($mdXml2);
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> // Read the WebLayout into an XML DOM document object.
>>>>
>>>> $wl = "Library://XXX/XXX.WebLayout"; // TODO Constant!
>>>>
>>>> $wlResourceId = new MgResourceIdentifier($wl);
>>>>
>>>> $wlReader = $resourceService->GetResourceContent($wlResourceId);
>>>>
>>>> $wlXml = $wlReader->ToString();
>>>>
>>>> $wlDomDoc = DOMDocument::loadXML($wlXml);
>>>>
>>>>
>>>>
>>>> // Now, update the MapDefinition.
>>>>
>>>> $mapdef = $wlDomDoc->getElementsByTagName("ResourceId")->item(0);
>>>>
>>>> $mapdef->nodeValue = "$md1";
>>>>
>>>>
>>>>
>>>> // Prepare the updated XML to be written out to the session.
>>>>
>>>> $wlupdatedXml = $wlDomDoc->saveXML();
>>>>
>>>> $wlbyteSource = new MgByteSource($wlupdatedXml, strlen($wlupdatedXml));
>>>>
>>>>
>>>>
>>>> // Create a temporary WebLayout
>>>>
>>>> $wlsessionMapName = $wlResourceId->GetName();
>>>>
>>>> $wlsessionWebLayout = 
>>>> "Session:$sessionId//$wlsessionMapName.WebLayout";
>>>>
>>>> $wlsessionResourceId = new MgResourceIdentifier($wlsessionWebLayout);
>>>>
>>>>
>>>>
>>>> // Write the updated WebLayout to the session.
>>>>
>>>> $resourceService->SetResource($wlsessionResourceId,
>>>> $wlbyteSource->GetReader(), null);
>>>>
>>>>
>>>>
>>>> // Redirect to the Ajax viewer.
>>>>
>>>> $redirectTo =
>>>> "mapguide/mapviewerajax/?SESSION=$sessionId&WEBLAYOUT=$wlsessionWebLayou
>>>> t";
>>>>
>>>> $host = $_SERVER["HTTP_HOST"];
>>>>
>>>> $url = "http://$host/$redirectTo";
>>>>
>>>>
>>>>
>>>> //Test
>>>>
>>>> $f = 'test.txt';
>>>>
>>>> $handle = fopen($f,"w");
>>>>
>>>> fwrite($handle, "test1:<".$mdXml.">\r\ntest 2 
>>>> :<".$updatedXml.">\r\ntest
>>>> 3 :<".$wlXml.">\r\ntest 4 :<".$wlupdatedXml.">\r\ntest 5 :<".$url.">");
>>>>
>>>> fclose($handle);
>>>>
>>>>
>>>>
>>>> // Redirect!
>>>>
>>>> header("Location: $url");
>>>>
>>>> exit;
>>>>
>>>>
>>>>
>>>> ?>
>>>>
>>>> ___________________________________________________________________________________
>>>> E-MAIL DISCLAIMER
>>>>
>>>> The present message may contain confidential and/or legally privileged 
>>>> information.
>>>> If you are not the intended addressee and in case of a transmission 
>>>> error,
>>>> please notify the sender immediately and destroy this E-mail.
>>>> Disclosure, reproduction or distribution of this document and its 
>>>> possible
>>>> attachments is strictly forbidden.
>>>>
>>>> SPACEBEL denies all liability for incomplete, improper, inaccurate, 
>>>> intercepted,
>>>> (partly) destroyed, lost and/or belated transmission of the current 
>>>> information
>>>> given that unencrypted electronic transmission cannot currently be 
>>>> guaranteed
>>>> to be secure or error free. Upon request or in conformity with formal, 
>>>> contractual
>>>> agreements, an originally signed hard copy will be sent to you to 
>>>> confirm
>>>> the information contained in this E-mail.
>>>>
>>>> SPACEBEL denies all liability where E-mail is used for private use.
>>>>
>>>> SPACEBEL cannot be held responsible for possible viruses that might 
>>>> corrupt this
>>>> message and/or your computer system.
>>>> ____________________________________________________________________________________
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> mapguide-users mailing list
>>>> mapguide-users at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>> _______________________________________________
>>>> mapguide-users mailing list
>>>> mapguide-users at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>> _______________________________________________
>>> mapguide-users mailing list
>>> mapguide-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>
>> _______________________________________________
>> mapguide-users mailing list
>> mapguide-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users 



More information about the mapguide-users mailing list