[OpenLayers-Users] Success! and one minor quirk :)

Stephen Woodbridge woodbri at swoodbridge.com
Fri Apr 9 00:05:10 EDT 2010


Hi Eric,

Sorry for the very long delay in getting back to this, but life happens 
regardless of code :) Questions inline below ...

Eric Lemoine wrote:
> On Wed, Mar 17, 2010 at 6:30 AM, Stephen Woodbridge
> <woodbri at swoodbridge.com> wrote:
>> Hi Eric and all,
>>
>> Thank you for your time and advice on this project, I think I finally
>> have almost everything working. There is still some clean up to do and a
>> few quirks that I'm not sure about. Oh and I need to add a user login so
>> different users edits are kept separate, but that is just some minor
>> coding at this point. Currently all edits are made to a test user table.
>>
>> http://imaptools.com:8080/tilecache/test.html?zoom=17&lat=33.89595&lon=35.49935&layers=BT
>>
>> So the one major annoyance left which I'm not sure what the issue is, is
>> that, if I edit POI and say change its "type" or its "name" fields the
>> POI on the vector layer should be destroyed and the new feature added
>> back into the layer. This is in fact happening, BUT the display of the
>> feature is not getting updated! until I click on the POI again.
>>
>> For example:
>>
>> 1) click left most tool
>> 2) select the "TEST" (or any) POI near the center of the viewport
>> 3) change its type and/or its name
>> 4) click [Save]
>> 5) notice the POI has not changed
>> 6) click it once and it changes
>> 7) click it again and the popup opens
>>
>> the protocol callback function is at line 422 of test.html and seems to
>> be doing the right thing except updating the layer when the a feature is
>> updated.
> 
> I think the callback function is not called at all. Have you tried to
> put a break point in this function? I think it's not called because
> the save strategy gives protocol.commit its own callback. Instead of
> setting "callback" in the protocol config, you should register
> listeners to the save strategy's "success" and "fail" events, and do
> the work there.

You are correct the callback is not getting called. So if I understand 
you suggestion correctly it would consist of doing something like this:

Openlayers.Request.events.on({
   success: function(event){ ... do something here ... },
   failure: function(event){ ... report problem here ... }
});

and this would catch these events when Strategy.Save runs. And this does 
catch these events. If this is correct, there is a problem that the 
event obj passed to the function only has request, config and requestURL 
objects and I need the response object to do my work. It looks like the 
request object contains the responseXML document, but this would then 
need to be reparsed via the OpenLayers.Format.MyXML to get the features 
array, which seems wasteful and redundant.

>> I thought maybe it was related to the select feature control,
>> but formAction() does unselect the feature.
> 
> it calls onUnselect, shouldn't it call unselect instead?

Oh, thanks, you are right. I didn't realize that I could do that and it 
makes sense because unselect allow OL to do its thing and then call my code.

Thank you for you support on this.

Best regards,
   -Steve

> Cheers,
> 




More information about the Users mailing list