0

I am looking for a marker plugin for leaflet that allows loading of markers dynamically, according to the current view.

E.g. I want to add OSM POIs to a world-wide map. Obviously loading all at once would be too much. Therefore, I'd only load markers on smaller areas when zoomed in. Is there a plugin that supports this functionality?

I know there is one for the overpass-api (https://github.com/kartenkarsten/leaflet-layer-overpass), but I do not want to spam the Overpass Api. Also the response is to slow for a customer facing application (IMHO). Additionally, I do not want to only map OSM POIs.

I thought about setting up my own DataBase and changing the leaflet-layer-overpass plugin to work with that, but that seems to be a lot of work. Is there maybe a pre-existing solution to the problem?

1

Building your own solution might actually not be as hard as you think.

All you would have to do is register a moveend event and then call getBounds() or getBoundsZoom() (in case the zoom level is important). Then you send this extent to your database and query all the points that fall within it. Of course you need a database that understands geospatial data. PostgreSQL/PostGIS would be an excellent option as you can see here.

  • Thanks for your comment. You have a really good point. I was hoping that there might be a pre-existing solution. Building it my-self would be possible though. – Robin Apr 26 '16 at 8:23
  • 1
    The hardest thing might just be getting the data and keeping it up to date. Other than that it should be pretty simple :-) – BritishSteel Apr 26 '16 at 8:37
  • You mean getting the POI data into the db or getting the POI data from the db to the map? – Robin Apr 26 '16 at 8:42
  • More getting into the DB. If you are using worldwide data then it might be hard to get all of that data. Or does Overpass let you download all the data of one type at once for the entire world? Not sure about that... Getting the data from the DB into the map will not be a problem as long as you know a server-side language that can talk to the DB and receive requests from your application. PHP would be a good choice as you do not need to install any additional modules. But there are plenty of other languages that could be used as well. – BritishSteel Apr 26 '16 at 8:51
  • 1
    You are right! I was thinking of Overpass Turbo, where you cannot download such masses of data, I think. Cool link, I will have a look at it! You can install PostGIS and you can send the data to your web application but to do this you need an intermediate language that can handle this, as you cannot use JavaScript to directly communicate with the DB. – BritishSteel Apr 26 '16 at 9:13

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.