[mapguide-users] Re: Need helps ~ How to programmatically add layer to initial map

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Sat May 17 07:32:39 EDT 2008


Hi Viva.

You should always write directly to the list, and directly to anyone.
That way others may respond better than me, or correct my mistakes.
It also enables others with a simillar problem to see the solution.

You need a form with a <input type=file> tag.
The user can then select the SHP file to upload.
You cannot upload a file from the user's machine in any other way for 
security reasons.

Once your server script recieves the file, it should validate the file, 
to ensure that it is not a dangerous file (eg. an executeable or defect 
shp file).
Then save the file in a temporary location with a random name.
Next step is to create a feature source. You can take an existing 
FeatureSource xml as a template.
In the feature source, update the path to point at the temporary file.
Save the feature source in the session repository.

Once you have the feature source, create a layerdefinition and point it 
to the temporary feature source.
Again, a template will make this easier.
Save the layer in the session repository.

Then load the runtime map, insert the new temporary layer in it, and 
save it.

Finally refresh the client display via. javascript.

The buffer functions of the viewer, also serves as examples of how to do 
this:
C:\program 
files\MapGuideOpenSource\WebServerExtensions\www\mapviewer(net/php/java)\buffer.(aspx/jsp/php)

More info on the repository and runtime map is avalible in the "MapGuide 
Developer Guide":
http://mapguide.osgeo.org/2.0/documentation.html

Regards, Kenneth Skovhede, GEOGRAF A/S



blackrose2142 at hotmail.com skrev:
> Hi kenneth,
>
> 1st of all, my name is Viva and very new beginner in gis web application using mapguide. I want to ask for ur help regarding how do i get my shp file that stored in C:\MySHP folder and uploaded it in my map default map? I need to programmatically it.
>
> Actually the flow of my web application is like this :-
>
> 1. Fill up query form and click 'Find' button
> 2. Once user click the 'find' button, it will execute my sql command to get 'the_geom' field value from my postgres database and created automatically a new SHP file and store it in C:\MySHP folder.
> 3. Last display the SHP file into my default map.
>
> Hope to hear from u soon.
>
> Viva
>   


More information about the mapguide-users mailing list