2

I'm working on a Ruby on Rails application that is showing road signs on the map(leaflet). So, user can browse map and road signs, great. But, if there are a lot of signs and user wants to zoom out, there are obvious problems for my app.

  • First problem is to prevent loading a lot of elements (signs) at the same time.
  • And the second problem is to have clear view of elements on the map.

This:

enter image description here

Insted of this:

enter image description here

Solution by my research is to cluster elements by locations as user is zoom-ing in and out. More precisely, using k-means algorithm.

My questions are :

  1. Are there some done solutions for this?
  2. If done solutions not exists, how to use k-means algorithm with zoom level?

I'm using Postgres database with Postgis extension and Ruby on Rails build API.

  • 1
    There are superb answers here: gis.stackexchange.com/questions/11567/… – Alexander Dec 21 '18 at 11:34
  • @alexander That are clustering algorithms but not anwsering my question – bKapusta Dec 22 '18 at 2:42
  • It is more usual to do this server side, for example, Leaflet's marker cluster control. This way you omly have one server round trip. – John Powell Dec 26 '18 at 18:27
  • @JohnPowell app is divided on server side API (Rails) and Front end (React), so if I want to use marker cluster control I need to send all of data at once from API to Front end to cluster control to work. Am I wrong? – bKapusta Dec 27 '18 at 11:42
  • That is correct. So it will be slower the first time to load, but much, much quicker on zoom. – John Powell Dec 27 '18 at 21:48

Your Answer

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

Browse other questions tagged or ask your own question.