We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey guys, searching for a helping hand. I'm trying to make a set of data visualisation code. The idea is to make an interactive world map that has pop ups (showing data) appear as you hover over a country. Is anyone be able to shed some insight? Much appreciated, cheers.
Answers
what do you have?
you need an image of the world and a set of coordinates telling you where each country is.
image() to display the map
mouseX(), mouseY(), dist() to work out if the mouse is near a data point
text() to draw the text.
Nothing yet, very new to coding world, but thanks for the tip. How would you recommend finding the corresponding coordinates of each country on the image?
Will the map be 2D or a 3D globe?
Where will the nation location data come from?
One approach:
These approach will work even if you are keeping your solid-color identifying map in an offscreen PGraphics or PImage buffer and displaying a different map on the screen -- like a contour map or a satellite image -- as long as the two line up.
Or:
Also, check out the unfoldingmaps library.
Hey, so I changed my concept slightly to simplify things - now just focusing on Australia rather than the world. My idea is too have large circles (with info inside) appear as the cursor hovers over each state. I added circles behind the image at each states coordinates in hope that they could be the trigger for the pop ups, but some of them will need to be bigger (as a pop up) to able to fit text inside. What code should I add to make this happen? Cheers, really appreciate any help!
ps. how should I post code? I used 'crtl+o' and 'pre lang="javascript"before and '/pre' after but it doesn't seem to be working just right. thanks again
(you only need ctrl-o)
the classic structure of a processing sketch includes setup() which is run only once and a draw() which is automatically called every 60th of a second or so. initialise things in setup, like loading the images. and do the interactive / animation things, like testing the mouse position and popping up the text, in draw.
read this:
https://forum.processing.org/two/discussion/8087/what-are-setup-and-draw
and this
https://forum.processing.org/two/discussion/8082/from-several-variables-to-arrays
(because having variables called a, b, c, d, e, f etc is terrible)
Good advice, thanks. Do you know what code is best to use to make the interactive component?
You can explore http://unfoldingmaps.org/
In the Processing IDE, go to the library manager and install the unfolding library. Then you can check the examples under File>>Examples** and then under *Contrubuted libraries>>Unfolding
For the coordinates of the countries, you will need to know them beforehand. You can google something like "countries latitude and longitude list"
However, first run the examples provided. You might have issues installing the library. If you do, let us know and I will be able to assist you sometime this weekend.
You can also check prev posts here in the forum. Try the keyword "unfolding".
Kf