[OpenLayers-Users] insert new geomtery attributes

ngreen n13green at gmail.com
Wed May 19 17:25:56 EDT 2010


There are others, but I used this example's basic form setup.

http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group.html
http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group.html 

For passing info to a database, AJAX can do that.

http://www.w3schools.com/ajax/default.asp
http://www.w3schools.com/ajax/default.asp 

The specific bits you really need are this (best defined globally):

		var xmlhttp;
		if (window.XMLHttpRequest)
			{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
			}
		else
			{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}

and then in your function to save you need something like:

			var geom_x = feature.geometry.x;
			var geom_y = feature.geometry.y;

		
xmlhttp.open("GET","proc/proc_map_point_new.php?"map_num="+map_num+"&x="+geom_x+"&y="+geom_y,true);
			xmlhttp.send();

and if you want to return a confirmation of the edit changes:

			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("edit_msg_" + fid).innerHTML="Saved";
			  }

And you'll obviously need to alter the GET url to include any extra
attributes you want to save to the database from the form.

Be aware that when referencing popup forms, each popup form field needs to
be unique and the feature.id is a good way to do that, eg.

			  <input type="text" id="edit_title_' + feature.id + '" maxlength="20"
size = "25" value ="' + feature.attributes.title + '">

And referencing that value to send it to the database would be:

		function editPoint(fid){
			var ed_id = document.getElementById("disp_id_" + fid).value;
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/insert-new-geomtery-attributes-tp5072541p5077033.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list