Database Entry Form

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Database Entry Form

jbanting
Hi All,

I’m looking to create a form to update, delete and create entries in a PostGIS enabled DB.  The layer that I want to update is being displayed by mapguide.

Currently I’m doing this on a separate form outside of mapguide, but I want to do this within mapguide now.

I’m relatively new to mapguide and fusion so my question is how difficult would it be to modify the selection widget to allow changes to the records it pulls.

Thanks!

James Banting
M.Sc Student
Department of Geography
University of Lethbridge
4401 University Drive
Lethbridge, Alberta, T1K 3M4

James Banting
M.Sc Student
Department of Geography
University of Lethbridge
4401 University Drive
Lethbridge, Alberta, T1K 3M4
Reply | Threaded
Open this post in threaded view
|

Re: Database Entry Form

mooman
James,

Probably the easiest thing I can think of is to use the InvokeURL tool. Open your layout and add that button somewhere in your toolbar.

Then i think Gordon did a good job of answering the rest here:

http://forums.autodesk.com/t5/Autodesk-MapGuide-Enterprise/Does-InvokeURL-work-in-Flexible-Fusion-layouts/td-p/2582570

From there, once you have the keys on the selection, you can query your PostGIS for the data and present a form. Then it's all PHP and PostGIS from there. (assuming you're using php).

Hope that helps!

----- Original Message -----
From: "jbanting" <[hidden email]>
To: [hidden email]
Sent: Monday, June 11, 2012 4:38:00 PM
Subject: [fusion-users] Database Entry Form

Hi All,

I’m looking to create a form to update, delete and create entries in a
PostGIS enabled DB.  The layer that I want to update is being displayed by
mapguide.

Currently I’m doing this on a separate form outside of mapguide, but I want
to do this within mapguide now.

I’m relatively new to mapguide and fusion so my question is how difficult
would it be to modify the selection widget to allow changes to the records
it pulls.

Thanks!

James Banting
M.Sc Student
Department of Geography
University of Lethbridge
4401 University Drive
Lethbridge, Alberta, T1K 3M4



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Database-Entry-Form-tp4980592.html
Sent from the Fusion Users mailing list archive at Nabble.com.
_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Reply | Threaded
Open this post in threaded view
|

Re: Database Entry Form

jbanting
Awesome! thanks for the link.

I would like users to modify values that are already being displayed in addition to adding new features so i think i will use the info in that link and modify a widget to do what i require. Maybe the buffer widget since it pulls the layer name from selected features already.  Ill use that the info in the link to pull other attributes about the selected feature then have php do an update and insert from the data pulled.  

Thanks for the guidance.
James Banting
M.Sc Student
Department of Geography
University of Lethbridge
4401 University Drive
Lethbridge, Alberta, T1K 3M4
Reply | Threaded
Open this post in threaded view
|

Re: Database Entry Form

jbanting
Hello,  

I created a new widget (for me to learn on really) but in the end used invokeURL to get the php i wanted.  The user can now update and insert new data via a form into my postgres db through the invokeURL widget.

When the user needs to create a new entry in the db I would like for them to be able to click on the map and get the lat long of where they clicked and for that lat long to be automatically inserted into my form.  I am able to get the lat long in an alert when the user clicks on the map using the select tool.
How would i pass these to my invokeURL widget?

From select.js

var center = this.map.getLonLatFromPixel(position);
               
center = center.transform(this.oMap.oMapOL.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
alert("You clicked at " + center.lat + " N, " +
                              + center.lon + " E");


Thanks,
James Banting
M.Sc Student
Department of Geography
University of Lethbridge
4401 University Drive
Lethbridge, Alberta, T1K 3M4
Reply | Threaded
Open this post in threaded view
|

Re: Database Entry Form

mooman
Hi James,

Well here's the funny part. InvokeURL is only good for sending you to a PHP script that is able to access session data of what you're doing (like selecting an existing feature). Seems like you'll have to write your own widget. Which can be a combination of the Select and Invoke tools.

Basically, you'll want something like activate and deactivate and a handler for click like Select. Once user clicks, you'll be able to run your code getting the lat/lon and pass it to a script by opening a window like Invoke does.

It may make more sense to have 2 buttons: one for creating a new point and another for editing existing points (which you can use what you already have).

I think it should be pretty simple to look at those 2 widgets and kindda combine them. But, again, feel free to ask more detailed coding questions also!
Reply | Threaded
Open this post in threaded view
|

Re: Database Entry Form

jbanting
Hi All,
With help from mooman, I was able to create a separate widget that connects to a postgis enabled db and allows updating and inserting records through the widget. I've included it in the attached zip file so if anyone else was looking for something like this, here ya go. DatabaseForm.zip
James Banting
M.Sc Student
Department of Geography
University of Lethbridge
4401 University Drive
Lethbridge, Alberta, T1K 3M4
Reply | Threaded
Open this post in threaded view
|

Re: Database Entry Form

Pedro Venâncio
Hi James,

Thank you for sharing, it's a very interesting and useful tool!

Can you please make a small documentation explaining how to put the tool running in order to be used by those who have little knowledge of PHP and that are just using the fusion templates? Maybe with some sample pictures of the tool working?

Thank you very much!

Best regards,
Pedro






----- Original Message -----
From: jbanting

Hi All,
With help from mooman, I was able to create a separate widget that connects
to a postgis enabled db and allows updating and inserting records through
the widget. I've included it in the attached zip file so if anyone else was
looking for something like this, here ya go.
http://osgeo-org.1560.n6.nabble.com/file/n4983292/DatabaseForm.zip
DatabaseForm.zip

-----
James Banting
M.Sc Student
Department of Geography
University of Lethbridge
4401 University Drive
Lethbridge, Alberta, T1K 3M4
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Database-Entry-Form-tp4980592p4983292.html
Sent from the Fusion Users mailing list archive at Nabble.com.
_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Reply | Threaded
Open this post in threaded view
|

Re: Database Entry Form

jbanting
As requested.  I put additional comments in the code as well.
DatabaseForm.zip
James Banting
M.Sc Student
Department of Geography
University of Lethbridge
4401 University Drive
Lethbridge, Alberta, T1K 3M4
Reply | Threaded
Open this post in threaded view
|

Re: Database Entry Form

Steve Golden
Thanks for posting...I haven't used it yet, but plan on taking a closer look at this in the near future.
Reply | Threaded
Open this post in threaded view
|

Re: Database Entry Form

Steve Golden
In reply to this post by jbanting
Since you are offering this code to the mapguide user community, perhaps you can add it to the code examples wiki:

http://trac.osgeo.org/mapguide/wiki/CodeSamples

It's a centralized place and easier to find than having to search through the forums.

Thanks,

Steve