How to refresh features on a OL3 map automatically?

المشرف العام

Administrator
طاقم الإدارة
I am using OL3 and GeoServer and PostGIS as database. My database is connected to GeoServer and OL3 conected to GeoServer and reads the points in database as vector layer and shows on the map.

My data are changed every 5 seconds (position of points). I want to refresh the map automatically each 5 seconds to show the movement of the points.

Is there any way to do this?

EDIT: I am using WFS like this:

var vectorSource = new ol.source.ServerVector({ format: new ol.format.GeoJSON(), loader: function(extent, resolution, projection) { var url = 'http://localhost:8000/geoserver/cite/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=cite:MyFeature&maxFeatures=50&outputFormat=application/json'; $.ajax({ url: url }) .done(loadFeatures); }});I can use window.setTimeout(function () { location.reload() }, 5000); in the loadFeatures function to reload the page each 5 seconds. It is working but I am searching for a better way which refreshes the features and not the complete map.



أكثر...
 
أعلى