[OpenLayers-Users] edit feature using popup OpenLayers.Ajax PHP and MYSQL

buzibuzi jobs.franklin at gmail.com
Sat Nov 26 15:51:40 EST 2011


Hi,
im quite new to OpenLayers.
i have managed to gather some examples into editing features using a popup,
posting to php and inserting points to a Mysql db.

however, the page refreshes when posting the data. i prefer to use AJAX  so
there is no refresh.

i'm assuming its because im using
OpenLayers.Protocol.HTTP
but shifting to
OpenLayers.Ajax.Request
didn't help much.

couldn't find any working example for this which is strange because there
must be a real demand for such an example.

perhaps the page refreshes on post because the popup is using a form ?


this is the strategy:


	 var mySaveStrategy = new OpenLayers.Strategy.Save({ auto: true });	

//new ajax
	 var myProtocolAjax = new OpenLayers.Ajax.Request("proc/newPoint.php", 
	   {  method: 'post', 
			  //postBody: pParams, 
			  parameters: {
				m: 'r',
				srs: 'EPSG:4326'
			}	, 
			  onSuccess: function(transport) { 
				// alert('Successful Connection'); 
			  }, 
			  onComplete: function(transport) { 
					// alert(transport.responseText); 
			  } 
		
	});
	
//old http
	var myProtocolHTTP = new OpenLayers.Protocol.HTTP({
		url: "proc/newPoint.php",
		params: {
			m: 'r',
			srs: 'EPSG:4326'
		},
		callback: function() { alert("User callback called!"); },
		format: new OpenLayers.Format.GeoJSON({
			ignoreExtraDims: true,
			internalProjection: map.baseLayer.projection//,
			//externalProjection: wgs84
		})
	});	




this is my popup:



function getPopupForm(feature, context) {

    var gid      = feature.attributes.gid      || '';
    var name     = feature.attributes.name     || '';
    var name_alt = feature.attributes.name_alt || '';
    var notes    = feature.attributes.notes    || '';
    var html = "<div>" +
        "<form action='' name='baloon'>" +
           "<input id='fgid' type='hidden' value='" +
              gid + "' />" +
        "<table id='baloon' cols='4' direction='rtl' border='0'>" +
        "<tr><td colspan='2' align='right'>" + gid + "</td><td >#</td></tr>"
+ 
       "<tr><td colspan='2' align='right'><input id='fname' type='text'
size='40' value='" +
           escapeApostrophe(name) + "' /></td><td align='right'></td>" + 
        "<tr><td colspan='2'align='right'><select id='ftype' type='text'
name='ftype'>" +
                           addPoiTypeOptions(feature.attributes.type) +
                           "</select></td><td align='right'>:type</td></tr>"
+	                           
        "<tr><td colspan='2'></td><td align='right'>:category</td></tr>"+				   
         "<tr><td align='right' colspan='3'>" +
         "<div class='select-line'><select id='ftype' type='text'
name='firstlevel'></select></div>" +
         "<div class='select-line'><select id='ftype' type='text'
name='secondlevel'></select></div>" + 
         "<div class='select-line'><select id='ftype' type='text'
name='thirdlevel' onChange='return selectthird()'>"+
         "</select></div></td></tr>" + 									                              
       "<tr><td colspan='2' align='right'><input id='fname_alt' type='text'
size='8' value='" +
           escapeApostrophe(name_alt) + "' /></td><td
align='right'>:text</td></tr>" +
       "<tr><td colspan='2'><textarea rows='5' id='fnotes' type='text'
cols='20' width='300' value='" +
       escapeApostrophe(notes) + "'> </textarea></td><td
align='right'>:comment</td></tr>" +
       "<tr><td align='left'>" +
           "<button type='submit'  id='baloon-save' value='Save'
onClick=\"formAction('save')\" />"+
           "</td><td align='right'>" +
           "<div class='select-line'>"+
           "<button type='submit' id='baloon-cancel' value='Cancel'
onClick=\"formAction('cancel')\" />&nbsp;" +
           "</div><div class='select-line'>"+
           "<button type='submit' id='baloon-delete' value='Delete'
onClick=\"formAction('delete')\" /></div>"+
           "</td></tr></table></form>" +
       "</div>";
       
    return html;
}

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/edit-feature-using-popup-OpenLayers-Ajax-PHP-and-MYSQL-tp7034629p7034629.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list