0

I have developed a python script to subscribe a WebSocket and retrieve the output stream. The output is position bus with X / Y info and the output is a json. This a snippet of code:

websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://xxxxxx/subscribe",
                          on_message = on_message,
                          on_error = on_error,
                          on_close = on_close)
ws.on_open = on_open
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})

Now I would like to show this real-time data into a web map as Leaflet. Or another framework. I can do this? Any idea or example? Thanks

APPGIS
  • 353
  • 1
  • 10
  • 20

1 Answers1

0

Well, leafletJS allows you to load JSON (geoJSON). You could take a look at this question displaying .json files in leaflet.

You could create a standard HTML page with a repeating loop (using setInterval)

Within that loop, you can have it read the JSON file and populate the map with markers (either clear old ones first, or only add the new ones... or timestamp your JSON files and always load the latest).

You will have to obviously format your output JSON file to match the geoJSON structure needed by leafletJS.

pookie
  • 3,796
  • 6
  • 49
  • 105