[Geomoose-users] Custom form in services
Bistrais, Bob
Bob.Bistrais at maine.gov
Thu Feb 14 06:36:46 PST 2013
Hi Boris,
Yes, this is possible. I've built a few custom forms into the services tab using PHP. In a nutshell, you can create a service in which the <url> tags point to a PHP file. You can pass any parameters to that PHP file via the service. Then you can write that PHP file to contain any custom inputs or formatting that you want.
To populate input values from a database-
In this example I am connecting to a dbf file called huc8dbf, and want to get unique values for an attribute called HUC8:
include('config.php');
header('Content-type: application/xml');
//Connect to the database
$objConnect = odbc_connect ('mapserver', '', '') or die('Could Not Connect to ODBC Database!');
$command = "SELECT DISTINCT HUC8 FROM huc8.dbf ORDER BY HUC8";
$query=odbc_exec($objConnect,$command) or die ("Error executing query");
//Now I create a variable called $resultshuc8. It contains the select tag and all the huc8 values that were fetched from the dbf...
//Notice the following line. Its onChange event will start another GeoMoose service, and also carries a parameter called geography_value to that service:
$resultshuc8="<select name='drainage' onchange='GeoMOOSE.startService(".'"StreamQuery2"'.",{geography_value:this.value})'>";
$resultshuc8.='<option value=""></option>';
while($row=odbc_fetch_array($query)){
$huc8 = $row['HUC8'];
$resultshuc8.='<option value="'.$huc8.'">'.$huc8.'</option>';
}
$resultshuc8.="</select>";
//Now format the results as XML so GeoMoose will display it in the service tab...
print "<results><html><![CDATA[";
print "<p/>Drainage<br/>";
print $resultshuc8;
print "]]></html></results>";
---What you will see in the service tab is a select tag containing the unique values for Huc8. When the user selects a value from the select, it will start another service called StreamQuery2, and deliver the selected value to that service.
HTH,
Bob
-----Original Message-----
From: geomoose-users-bounces at lists.osgeo.org [mailto:geomoose-users-bounces at lists.osgeo.org] On Behalf Of Boris
Sent: Thursday, February 14, 2013 8:45 AM
To: geomoose-users at lists.osgeo.org
Subject: [Geomoose-users] Custom form in services
Hi i am very new to Geomoose and loving it so far.
I wanted to ask if there was a way to put a custom built form into the services tab instead of using the geomoose inputs? or if there would be a way to create a dynamic input type=select?
I wanted the select to be populated by values returned from the database.
I also wanted to ask if it is possible, in a custom input, to check what the previous steps input values were so that i could set options for the Openlayers regular polygon handler.
Thank you very much
Boris
_______________________________________________
Geomoose-users mailing list
Geomoose-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geomoose-users
More information about the Geomoose-users
mailing list