Skip to content
Advertisement

plot lightning data in Google maps

I’ve got a weather website, which misses lightning data. I found a data source from Blitzortung.org wich contains the Lat, Lon and time info of a lightning strike. How do I get this on Google Maps?

I want the data to be realtime, just like on blitzortung.org. It should be displayed on the map, preferably as a red or yellow dot, changing color as it ages (probably a JavaScript or PHP function that can edit css to do this) and of course on the right place.

I unfortunately had no experience with JSON and SQL, but don’t call me lazy because I don’t have the time to really learn this. I’ve got the map and the radar overlay which updates every 5 minutes: http://met.nl.eu.org/radar.html

this is the data source: http://www.lightningmaps.org/live/ I can use this source, provided that I will not use it for profit and that I add link to Blitzortung.org

So my main question is, how do I get Google maps to interpret the coords in the JSON file as places on the map, and draw a marker on the place, which changes color as it ages?

server:

Ubuntu with Apache,
SQL databases,
PHP5
and python for image processing


Edit: this script might help a bit more:

JavaScript

Just ignore the audio part, as I will not need it.


Edit: I’ve changed my needs. The first priority is to get the lightning strikes on the right place. The changing of color and stuff might come in a later point of the development but for now just the data on the map is fine.

Advertisement

Answer

1) Create a PHP script that will open and read the json from the live URL:

File: get_lightnings.php

JavaScript

This will read and echo the json.

2) Query that URL with javascript by using AJAX. Here is an example map script that will query the PHP file with jQuery.ajax() and create a marker for each lightning:

JavaScript

Below is the full HTML page for you can copy it right away and test it.

JavaScript

This was tested and is working fine.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement