5
Wombat
6y

Have you ever worked with leaflet.js to display openstreetmap? I do and its great.

But now I want to display multiple markers on a map and the map somehow only renders random three markers. Wtf?

I'm lost. All results on google show me how to do it right, but it just doesn't work.

Comments
  • 2
    Race condition?
  • 0
    @Root
    Call me out if I'm wrong, but isn't JS single threaded, so no race-conditions possible?
  • 4
    @metamourge You're right, js is single-threaded. But it also supports async functions, which run in arbitrary order, and with shared / incorrectly-scoped variables (etc.) this can absolutely lead to race conditions.
  • 1
    @Root
    Ah,OK.
    I was thinking of race-conditions, as in,
    Two threads run simultaneously, one modifies a variable, the other reads it at the same time.
  • 2
    @metamourge Yep yep. Two implementations of the same issue.

    And they're much harder to debug in a multithreading environment!
  • 1
    I have used it, though about 2 years ago...
    Something was about marker groups.
    Maybe you overwrite an object reference or similar.
  • 1
    @Root @metamourge no race condition, markers get added in a simple for loop.
  • 1
    @PonySlaystation thanks, that's a new trace I can hunt down.
  • 1
    @PonySlaystation @Root @metamourge

    I solved it. The problem was trivial. I was dumb. It only rendered three random markers, because I only fetched fucking three random locations.

    😐

    Damn, that shit ate a lot of time...
  • 1
  • 2
  • 1
    @PonySlaystation I really like leaflet.js for working with openstreetmaps. Do you know how to change the map tiles to another style? Or change the language used on the tiles?
  • 2
    @Wombat Oh... I have not done that specific case yet... I've only used leaflet in one project with a group of SVGs as the map (no tiles).

    You can see it on http://www.afbn.ch/map/ 😉
    I had to use HTML Markers, but the code is relatively ugly and it runs on WordPress 🤮🤣

    AfBN is a regional (government-funded) organization to keep the regional highways in shape, do highway snow plowing, tunnel maintenance and highway accident response.
  • 1
    @PonySlaystation man, that looks awesome!! Very creative. I really like the design.
  • 1
    @Wombat Thanks 😄
    Yeah, the design agecy really did a great job. It was not a cheap website. 😄
  • 2
    @PonySlaystation

    The hero we need.

    These are the sort of projects that improve society as a whole.
Add Comment