Manually refresh layer

325 views
Skip to first unread message

Bryan McBride

unread,
Feb 29, 2012, 4:37:16 PM2/29/12
to Leaflet Vector Layers
Is there currently any direct function you can call to refresh a
layer? I know I can set my layer to be 'dynamic', but I still must
force an extent change for the layer to refresh. Any advice would be
most appreciated- thanks!

Jason Sanford

unread,
Feb 29, 2012, 4:42:51 PM2/29/12
to leaflet-ve...@googlegroups.com
Besides also using the `autoUpdate` and `autoUpdateInterval` parameters to refresh the vectors every X seconds, there isn't a way to explicitly update the layer without using the private `_getFeatures` method (which should work I think).

If you think a refresh method would be handy file an issue … shouldn't be much work at all, probably just calling _getFeatures

If you think that would be users

Bryan McBride

unread,
Mar 1, 2012, 10:18:35 AM3/1/12
to leaflet-ve...@googlegroups.com
I can't seem to get the  `_getFeatures` method to work...  I'm using a PRWSF layer with dynamic: true set. After editing an attribute in PostGIS, calling mylayer._getFeatures() doesn't seem to do anything. As a workaround, I can remove the layer and re-add it back to the map, but there should be a better way to do this. Let me know what you think and I can add open an issue in Github.

Thanks!
--
Bryan R. McBride, GISP
bryanmcbride.com

Jason Sanford

unread,
Mar 1, 2012, 12:38:24 PM3/1/12
to leaflet-ve...@googlegroups.com
Yeah. I'd feared that it would be a bit more complex that a simple `_getFeatures`. If this is a public app I could take a look. Otherwise I can probably look at it this weekend.

Thanks
Jason

Bryan McBride

unread,
Mar 1, 2012, 6:35:48 PM3/1/12
to leaflet-ve...@googlegroups.com

Yeah, no worries. Whenever you get some time. My workaround should be fine for the time being.

Thanks!

Bryan R. McBride, GISP
bryanmcbride.com

Reply all
Reply to author
Forward
0 new messages