[OpenLayers-Users] Questions on using Protocol.HTTP and custom XML
to load/edit features
Stephen Woodbridge
woodbri at swoodbridge.com
Mon Mar 8 00:20:14 EST 2010
Hi all,
I am trying to implement a vector layer that will allow editing point
data. The data is accessed via a PHP script that serves some arbitrary
XML. The layer looks like this so far:
vector = new OpenLayers.Layer.Vector("POI", {
maxResolution: 360.0/16777216/2, // zoom 15
styleMap: styleMap,
protocol: new OpenLayers.Protocol.HTTP({
url: "poi-server.php",
params: {
m: 'r',
srs: 'EPSG:4326'
},
format: new OpenLayers.Format.XML()
}),
strategies: [
new OpenLayers.Strategy.BBOX({ratio: 1}),
new OpenLayers.Strategy.Save({
auto: true//,
//save: function() { alert("Save called."); }
}),
]
});
This seems like it almost works. But has the following problems, so
maybe I'm just taking the wrong approach all together. Here is a live
example:
http://imaptools.com:8080/tilecache/test.html?zoom=17&lat=33.89595&lon=35.49935&layers=BT
Issue:
1) the feature request does not seem to load on page load, but fires if
you pan the map slightly
2) when the features load, I get an error on line 128 of
OpenLayers/Format/XML.js because test.indexOf() is not a method. This is
because text is type Document not string?
3) I assume the the XML parser will parse the response into an
appropriate tree object, then I need to add some code that reads the
tree and constructs feature objects that I then add to the layer. So is
the problem above because the text object passed to read IS my tree and
I need to pass a my own read() function to some code to do that? Where
do I do that?
4) If I add a point using the toolbar add point button, I get
Security error" code: "1000
http://imaptools.com:8080/ol28/lib/OpenLayers/Format/XML.js
Line 198
data = serializer.serializeToString(node);
What is this error and why am I getting it? I assumed that a default
serializer exists, I probably need to add my own it write the expected
XML the the PHP needs. Where would I add this and what are the exected
inputs and outputs?
5) I eventually need to issue the Ajax requests by sending XML documents
to the server instead of issuing GET requests. So to do this I assume I
need to a) write code to serialize some params into a document, then b)
get HTTP protocol to send the document. How do I do this? The PHP code
is only temporary for testing and developing in my environment.
I learned a lot today, just by reading lots of OL code but I still have
a ways to go.
I would appreciate and help and guidance.
Thanks,
-Steve
More information about the Users
mailing list