I have GPS unit which update the DB with Points every 10 seconds. I want to show the position in real time (as much as I can) on map using OL or Leaflet. What I did is serving the Point as Layer in Geoserver and using it as WMS layer and redraw it every 2s (to show update asap).

Thing is that this solution feels kinda slow/heavy on performance... and in Leaflet the WMS layer flickers every redraw.

Is there a better way to do such thing ?

  • What Database (DB) are you using?
    – Mapperz
    Jul 11, 2013 at 21:49
  • MSSQL 2012 with Geometry. I also have PostGIS installed , but its easier to work with MSSQL when writing .Net apps.
    – Alophind
    Jul 11, 2013 at 22:24

1 Answer 1


I would tackle this problem as follows:

  • Write a webservice which returns the latest/current position of the GPS unit as GeoJSON.
  • Have Google/Bing/OSM/whatever as a base layer, in the Leaflet application
  • Have a Vector Layer in the map to show the current point.
  • Every 10 seconds , using JavaScript, I would query the webservice, and get the latest position of the point. Once the new position is received, I would draw that as a graphic in the vector layer.

Using a vector layer instead of a wms layer has the following advantages:

  • Less data needs to be transferred. The GeoJSON will be orders of magnitude smaller in size than the image from a WMS service.
  • You will not have to face the 'flickering' that you see right now.
  • If required you can change the style of the point. For example, if point has moved from the last location, show it as red, and if it has not moved more than say 10m, show it as green and so on.
  • Thank you very much for your answer , Is GeoJSON better than Markers for such a task ?
    – Alophind
    Jul 12, 2013 at 5:45
  • @Alophind: GeoJSON is a data transfer protocol. Markers are what you use to show the points on a Leaflet map. Jul 12, 2013 at 5:56
  • But I can do it as Markers or Vector layer with Points. What will be the difference?
    – Alophind
    Jul 12, 2013 at 6:00
  • 1
    In Leaflet, L.GeoJSON is a special Layer that can be used when you have GeoJOSN data. For points, by default, it uses markers. You can override the style, by using L.GeoJSON.setstyle() method. In certain cases, like the example I have given in my answer, using a style might be easier. It all comes down to your preference. When I said 'vector layer' I meant in the terms of a generic vector v/s raster paradigm. Jul 12, 2013 at 6:05
  • Is there a way to do it persistent ? so when the data change it auto refresh (instead of querying the Web-service every 2 sec)
    – Alophind
    Jul 12, 2013 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.