How do you create an array to store geolocation which can appear on a map?

I have a csv file which states the names of cities of UK that have different geolocations for each cities. Considering theres over 10 cities i would like to store these cities into an array and then have them mapped onto each city area of the UK map.

How do i create an array that would read each city along with the latitude and longitude in order to have them mapped onto the UK map and when they are mapped i would want each city location to be clickable so it displays a text.

I have three different screens for different years of the cities, so when i click each screen it shows different data and this is where it gets confusing as i have no idea of how and where i would need to put it.

I can send the code over by PM for anyone who can assist me with it.

1 Like

Hello!

Okay, you can load csv data with loadStrings, then for loop and split()

You can display geo data with a library unfolding maps, search it here on the forum
see https://discourse.processing.org/search?q=unfolding%20maps

to show different years: let’s say you press 1 for 2015, 2 for 2016 and 3 for 2017, set a String in keyPressed() to these years and evaluate in draw().

Chrisir

Example Sketch


String year = "2015"; 

void setup() {
  size (600, 600);
}

void draw() {
  background(17);

  switch (year) {

  case "2015":
    background(17); 
    fill(255); 
    text("Year 15...", 100, 100);
    break; 

  case "2016":
    background(177);
    fill(0); 
    text("Year 16...", 100, 100);
    break; 

  case "2017":
    background(17);
    fill(255); 
    text("Year 17...", 100, 100);
    break;
  }//switch
}//func 

void keyPressed() {
  switch (key) {
  case'1':
    year="2015";
    break;

  case'2':
    year="2016";
    break;

  case'3':
    year="2017";
    break;
  }//switch
  //
}//func
//
1 Like

You can use loadStrings or loadTable.

The Table object is a bit more complex to work with, but it is designed to work with csv format data of different column data types. It will let you store names, lat/long floats, and other metadata in each TableRow so that you can loop over them for display or look them up by index or name value.