[OpenLayers-Users] Saving vector features in various formats
paweluz
paweluz at o2.pl
Sat Feb 6 06:11:31 EST 2010
Hi Max!
I am using Openlayers, Geoserver, Postgis on Windows XP. I was thinking that
adding new object into database would be difficult but is was not. I am
using only JS. I do not use any PHP or something like that. I add a new
object into database with: road geometry, id of road and name of road. Here
is some of my code. Hope it could help you:
drawControls = {
......
add_object:new OpenLayers.Control.DrawFeature(
zielona_wfs, OpenLayers.Handler.Path
),
....
};
drawControls["add_object"].featureAdded = function(feature) {
feature.layer.eraseFeatures([feature]);
feature.geometry = new OpenLayers.Geometry.MultiLineString(
feature.geometry
);
selectedfeature=feature; //global variable
feature.state = OpenLayers.State.INSERT;
feature.layer.drawFeature(feature);
}
I get the id and name from html input text element. I add new object on
button click (function add_object).
function add_object() {
selectedfeature.attributes['Id']
=parseInt(document.getElementById("id_geometry").value);
selectedfeature.attributes['Road'] =
document.getElementById("road_geometry").value;
map.layers[1].commit();
document.getElementById("id_geometry").value="";
document.getElementById("road_geometry").value="";
//return false;
}
After adding new object you should get alert (SUCCESS). BTW, i do not know
how to remove this alert, other then looking into source code. maybe you
will figure it out. Hope I helped you
Cheers,
Poul
--
View this message in context: http://n2.nabble.com/Saving-vector-features-in-various-formats-tp4512698p4524884.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list