Location: PHPKode > scripts > Form Builder > form-builder/examples/using_google_maps.php
<?
/*Include Form Class*/
include("../class.form.php");

if(!isset($cmd))
	$cmd = "";

if($cmd == "submit")
{
	/*Handles Form Post*/
	echo("<pre>");
	print_r($_POST);
	echo("</pre>");
	exit();
}

if($cmd == "")
{
	?>
	<html>
		<head></head>
		<body>
			<h2 style="text-align: center; margin: 0; padding: 0;">Form Builder Class - Examples</h2>
			<h5 style="text-align: center; margin: 0; padding: 0;"><span style="padding-right: 10px;">Author: Andrew Porterfield</span><span style="padding-right: 10px;">Released: April 24, 2009</span><span>Version: 0.4.0<span></h5>
			<a href="../index.html">Back to Project Home Page</a>
			<p><b>Using Google Maps Form Field</b> - Included in this form builder class is a hybrid field for capturing a latitude/longitude pair by utilizing the Google Maps API.
			One important thing to notice about this form field is that you must specify a form attribute parameter titled googleMapsAPIKey.  If you have worked with the Google Maps API,
			you should be familiar with this key.  If not, let me briefly explain why this is necessary.  To use the Google Maps API in your website, you must first register the domain you
			will be using the web service.  Registration can be found on http://code.google.com/apis/maps/signup.html.  Once you have submitted your domain, you will be provided with a lengthy
			key that identifies your domain when using the web service.  This key needs to be copy and pasted into the googleMapsAPIKey form attribute.  If you have already registered your domain, obviously you
			will not have to go through the process again.  Just insert your existing key and you will be all set.  To specifiy a location, simply click, drag, and drop the marker on the map to 
			a given point.  Once dropped, the lattitude and longitude will be inserted into the textbox above the map.  This data will need to be parsed once submitted - I recommend using explode() on the "," and substring() on each piece.<p>
			<?

			$form = new form();
			$form->setAttributes(array(
				"googleMapsAPIKey" => "ABQIAAAAGkAXtILEQ0HGorBDDXXyDxQfYTdFkbZjcQSPkKwdAKL2zU_aExSMelXtVbKbqmiUHq3bbCg5YhjPJA",
				"tableAttributes" => array("width" => "500")
			));

			$form->addHidden("cmd", "submit");
			$form->addLatLng("Detault LatLng Functionality:", "field0");
			$form->addLatLng("Pre-Filled LatLng Functionality:", "field1", array(40.737, -73.994));
			$form->addLatLng("Customized LatLng Functionality:", "field2", array(40.737, -73.994), array("latlngZoom" => 5, "latlngHeight" => 400, "latlngWidth" => 400));
			//----------------------------------------------------------------------------------

			//Add Submit Button
			$form->addButton();

			//Render Form HTML
			$form->render();
			?>
			<a href="../index.html">Back to Project Home Page</a>
		</body>
	</html>	
	<?
}
?>

Return current item: Form Builder