Re: [OpenLayers-Users] Questions on using Protocol.HTTP and custom XML to load/edit features

2010-03-14 Thread Stephen Woodbridge
Eric Lemoine wrote:
> On Wed, Mar 10, 2010 at 6:21 PM, Stephen Woodbridge
>  wrote:
>> I'm running OL 2.8, I have not tried trunk.
>>
>> http://imaptools.com:8080/tilecache/test.html?zoom=17&lat=33.89595&lon=35.49935&layers=BT
>>
>> This is a work in progress, that is getting edits, but demonstrates the
>> issue.
>>
>> 1) Turn on Firebug
>> 2) load the page
>> 3) verify in the FB->"Net" tab that
>> http://imaptools.com:8080/tilecache/poi-server.php?...
>> has not been called.
>> 4) Either pan view slightly ot toggle Vector layer off/on in layerswitcher
>> 5) Notice in FB->"Net" tab the poi-server.php is called.
> 
> Hi Steve.
> 
> I think I know what's going on, and it isn't a bug in the lib.
> 
> init does not call zoomToMaxExtent, because the ArgParser control,
> which the map constructor includes by default, already called
> setCenter. The ArgParser calls setCenter when the WMS layer is added,
> i.e. before the BBOX strategy is activated, so the BBOX strategy
> doesn't catch the first moveend. I'm pretty sure that setting controls
> to null in the map options makes the problem go away.
> 
> Cheers,
> 

Hi Eric,

Thanks that worked. I added:

controls: [],

to my map definition and it cleared up the problem. That is a very 
subtle effect that I'm not sure I would have figured out on my own.

Best regards,
   -Steve
___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] Questions on using Protocol.HTTP and custom XML to load/edit features

2010-03-14 Thread Eric Lemoine
On Wed, Mar 10, 2010 at 6:21 PM, Stephen Woodbridge
 wrote:
> I'm running OL 2.8, I have not tried trunk.
>
> http://imaptools.com:8080/tilecache/test.html?zoom=17&lat=33.89595&lon=35.49935&layers=BT
>
> This is a work in progress, that is getting edits, but demonstrates the
> issue.
>
> 1) Turn on Firebug
> 2) load the page
> 3) verify in the FB->"Net" tab that
> http://imaptools.com:8080/tilecache/poi-server.php?...
> has not been called.
> 4) Either pan view slightly ot toggle Vector layer off/on in layerswitcher
> 5) Notice in FB->"Net" tab the poi-server.php is called.

Hi Steve.

I think I know what's going on, and it isn't a bug in the lib.

init does not call zoomToMaxExtent, because the ArgParser control,
which the map constructor includes by default, already called
setCenter. The ArgParser calls setCenter when the WMS layer is added,
i.e. before the BBOX strategy is activated, so the BBOX strategy
doesn't catch the first moveend. I'm pretty sure that setting controls
to null in the map options makes the problem go away.

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemo...@camptocamp.com
http://www.camptocamp.com
___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] Questions on using Protocol.HTTP and custom XML to load/edit features

2010-03-11 Thread Stephen Woodbridge
Stephen Woodbridge wrote:
> Eric Lemoine wrote:
>> On Monday, March 8, 2010, Stephen Woodbridge  wrote:
>>> OK, to partially answer some of my own questions ... inline below.
>>>
>>> Stephen Woodbridge wrote:
 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?
>>> This appears to be because I need to write my own class like
>>> OpenLayers.Format.MyXML that parses the XML document the PHP returns and
>>>   returns an array of features. Working on writing this.
>>>
 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?
>>> See 2) above.
>>>
 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?
>>> I'm hoping this is probably related to the above. will report back after
>>> I get my XML parser working.
>>>
 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.
>>> Any thoughts on 1) or 5)? Just a pointer would be helpful :)
>> Hi Steve.
>>
>> For 1) what version of OL are you using? I thought this issue was
>> fixed a while back. A test case demonstrating the problem would be
>> useful.
> 
> Hi Eric,
> 
> I'm using OpenLayers 2.8. Did you have a chance to verify when this was 
> fixed? Do I need to write a bug for this? I looked through the open bugs 
> but did not see anything that fit this issue.

I just found a simple work around to this problem. At the end of my 
init() I added:

 // work around a bug loading features
 vector.setVisibility(false);
 vector.setVisibility(true);

Which seems to force the loading of the features on the vector layer.
Annoying, but a simple fix.

I also checked this on trunk and I get the same behavior. It is also 
possible that I have done something stupid in my layer definition that 
might be causing this, but if I did its not obvious to me as I have 
looked over my code a few times.

-Steve

> Thanks,
>-Steve
> 
> 
>> For 5) the HTTP protocol has a readWithPost option that allows sending
>> read requests with POST instead of GET. But I don't think it'll work
>> in your case because you it will post encoded params, and you won't be
>> able to provide it with your XML document. So I think you need to
>> implem

Re: [OpenLayers-Users] Questions on using Protocol.HTTP and custom XML to load/edit features

2010-03-11 Thread Stephen Woodbridge
Eric Lemoine wrote:
> On Monday, March 8, 2010, Stephen Woodbridge  wrote:
>> OK, to partially answer some of my own questions ... inline below.
>>
>> Stephen Woodbridge wrote:
>>> 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?
>> This appears to be because I need to write my own class like
>> OpenLayers.Format.MyXML that parses the XML document the PHP returns and
>>   returns an array of features. Working on writing this.
>>
>>> 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?
>> See 2) above.
>>
>>> 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?
>> I'm hoping this is probably related to the above. will report back after
>> I get my XML parser working.
>>
>>> 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.
>> Any thoughts on 1) or 5)? Just a pointer would be helpful :)
> 
> Hi Steve.
> 
> For 1) what version of OL are you using? I thought this issue was
> fixed a while back. A test case demonstrating the problem would be
> useful.

Hi Eric,

I'm using OpenLayers 2.8. Did you have a chance to verify when this was 
fixed? Do I need to write a bug for this? I looked through the open bugs 
but did not see anything that fit this issue.

Thanks,
   -Steve


> For 5) the HTTP protocol has a readWithPost option that allows sending
> read requests with POST instead of GET. But I don't think it'll work
> in your case because you it will post encoded params, and you won't be
> able to provide it with your XML document. So I think you need to
> implement your own protocol, possibly by extending/overriding
> Protocol.HTTP.
> 
> Cheers,
> 

___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] Questions on using Protocol.HTTP and custom XML to load/edit features

2010-03-10 Thread Stephen Woodbridge
Eric Lemoine wrote:
> On Monday, March 8, 2010, Stephen Woodbridge  wrote:
>> OK, to partially answer some of my own questions ... inline below.
>>
>> Stephen Woodbridge wrote:
>>> 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?
>> This appears to be because I need to write my own class like
>> OpenLayers.Format.MyXML that parses the XML document the PHP returns and
>>   returns an array of features. Working on writing this.
>>
>>> 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?
>> See 2) above.
>>
>>> 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?
>> I'm hoping this is probably related to the above. will report back after
>> I get my XML parser working.
>>
>>> 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.
>> Any thoughts on 1) or 5)? Just a pointer would be helpful :)
> 
> Hi Steve.
> 
> For 1) what version of OL are you using? I thought this issue was
> fixed a while back. A test case demonstrating the problem would be
> useful.

I'm running OL 2.8, I have not tried trunk.

http://imaptools.com:8080/tilecache/test.html?zoom=17&lat=33.89595&lon=35.49935&layers=BT

This is a work in progress, that is getting edits, but demonstrates the 
issue.

1) Turn on Firebug
2) load the page
3) verify in the FB->"Net" tab that 
http://imaptools.com:8080/tilecache/poi-server.php?...
has not been called.
4) Either pan view slightly ot toggle Vector layer off/on in layerswitcher
5) Notice in FB->"Net" tab the poi-server.php is called.

> For 5) the HTTP protocol has a readWithPost option that allows sending
> read requests with POST instead of GET. But I don't think it'll work
> in your case because you it will post encoded params, and you won't be
> able to provide it with your XML document. So I think you need to
> implement your own protocol, possibly by extending/overriding
> Protocol.HTTP.

OK, I think I have this part figured out. I am solving this by writing 
OpenLayers.Format.MyXML class. You can see it in the top of my html 
page. So it looks like HTTP protocol implements a REST protocol, so as 
long as my PHP implements a REST interface using the Format, I think it 
will work. I'm still wading neck deep in this code. Format has 
properties

Re: [OpenLayers-Users] Questions on using Protocol.HTTP and custom XML to load/edit features

2010-03-09 Thread Eric Lemoine
On Monday, March 8, 2010, Stephen Woodbridge  wrote:
> OK, to partially answer some of my own questions ... inline below.
>
> Stephen Woodbridge wrote:
>> 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?
>
> This appears to be because I need to write my own class like
> OpenLayers.Format.MyXML that parses the XML document the PHP returns and
>   returns an array of features. Working on writing this.
>
>> 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?
>
> See 2) above.
>
>> 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?
>
> I'm hoping this is probably related to the above. will report back after
> I get my XML parser working.
>
>> 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.
>
> Any thoughts on 1) or 5)? Just a pointer would be helpful :)

Hi Steve.

For 1) what version of OL are you using? I thought this issue was
fixed a while back. A test case demonstrating the problem would be
useful.

For 5) the HTTP protocol has a readWithPost option that allows sending
read requests with POST instead of GET. But I don't think it'll work
in your case because you it will post encoded params, and you won't be
able to provide it with your XML document. So I think you need to
implement your own protocol, possibly by extending/overriding
Protocol.HTTP.

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemo...@camptocamp.com
http://www.camptocamp.com
___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] Questions on using Protocol.HTTP and custom XML to load/edit features

2010-03-08 Thread Stephen Woodbridge
OK, to partially answer some of my own questions ... inline below.

Stephen Woodbridge wrote:
> 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?

This appears to be because I need to write my own class like 
OpenLayers.Format.MyXML that parses the XML document the PHP returns and 
  returns an array of features. Working on writing this.

> 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?

See 2) above.

> 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?

I'm hoping this is probably related to the above. will report back after 
I get my XML parser working.

> 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.

Any thoughts on 1) or 5)? Just a pointer would be helpful :)

Perseverance pays off,
   -Steve

> Thanks,
>-Steve
> ___
> Users mailing list
> Users@openlayers.org
> http://openlayers.org/mailman/listinfo/users

___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users