Utilizing Data-Driven Documents to combine JSON
data with Google Maps
. The JavaScript
code places a circle and label at a specified station location. Check out this example.
Here is the relevant JavaScript
file.
And here is the corresponding JSON
file.
Included in the JSON
data are pH levels and soil chemistry information for each station, like station 24:
"24": {
"latitude": 31.967240000000004,
"longitude": -111.09028,
"pH Buffer": 0.0,
"pH": 7.53,
"Aluminum": 25.28,
"Antimonies": 0.32,
"Arsenic ": 0.08,
"Barium": 46.27,
"Beryllium": 0.2,
"Boron": 0.66,
"Cadmium": 0.03,
<more>
"Zinc": 0.15
},
The JSON
file will be updated to present chemistry data in quotes along with measurement symbols (mg/kg).
How can we modify the JavaScript
to display chemical details on mouseover
.
We aim to create an effect similar to what's done for US Congressional Districts and the New York Times.
Both examples have pop-up information displayed upon mouseover
(NYT) or mouseclick
(US Congressional Districts).
In the case of US Congressional Districts, the map and pop-up info are generated using GitHub services. Only a subset of the information from the GeoJSON
file appears in the pop-up.
For instance:
"properties": {"startcong": "103", "district": "0", "statename": "Wyoming", "endcong": "112", "id": "056103112000"}
This is transformed into a pop-up table:
| startcong | 103 |
| district | 0 |
| statename | Wyoming |
| member | [object Object] |
| endcong | 112 |
| id | 056103112000 |
We are interested in integrating a service comparable to GitHub's, but suitable for a standalone HTML + JS
document.