title: Adding markers to a unfolding map in Java
body: <p>I need to add code to display a marker at the location of each earthquake in the RSS feed and make the radius of each marker 10 by modifying the methods (and adding new helper methods as necessary). Then I need to add code to style each marker according to the magnitude of its earthquake.</p>
  
  <p>I know that I should create a SimplePointMarker object for each PointFeature in the list features, inside the setUp method for making markers appear on the screen, so it'll probably involve for each loops, but other then that I'm not sure how to code this.</p>
  
  <p>Unfolding marker package explanation...<a href="http://unfoldingmaps.org/javadoc/" rel="nofollow">http://unfoldingmaps.org/javadoc/</a></p>
  
  <pre><code>public class EarthquakeCityMap extends PApplet {
  
      // You can ignore this.  It's to keep eclipse from generating a warning.
      private static final long serialVersionUID = 1L;
  
      // IF YOU ARE WORKING OFFLINE, change the value of this variable to true
      private static final boolean offline = false;
  
      // Less than this threshold is a light earthquake
      public static final float THRESHOLD_MODERATE = 5;
      // Less than this threshold is a minor earthquake
      public static final float THRESHOLD_LIGHT = 4;
  
      /** This is where to find the local tiles, for working without an Internet connection */
      public static String mbTilesString = "blankLight-1-3.mbtiles";
  
      // The map
      private UnfoldingMap map;
  
      //feed with magnitude 2.5+ Earthquakes
      private String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.atom";
  
  
      public void setup() {
          size(950, 600, OPENGL);
  
          if (offline) {
              map = new UnfoldingMap(this, 200, 50, 700, 500, new MBTilesMapProvider(mbTilesString));
              earthquakesURL = "2.5_week.atom";   // Same feed, saved Aug 7, 2015, for working offline
          }
          else {
              map = new UnfoldingMap(this, 200, 50, 700, 500, new Google.GoogleMapProvider());
              // IF YOU WANT TO TEST WITH A LOCAL FILE, uncomment the next line
              //earthquakesURL = "2.5_week.atom";
          }
  
          map.zoomToLevel(2);
          MapUtils.createDefaultEventDispatcher(this, map);   
  
          // The List you will populate with new SimplePointMarkers
          List&lt;Marker&gt; markers = new ArrayList&lt;Marker&gt;();
  
          //Use provided parser to collect properties for each earthquake
          //PointFeatures have a getLocation method
          List&lt;PointFeature&gt; earthquakes = ParseFeed.parseEarthquake(this, earthquakesURL);
  
          // These print statements show you (1) all of the relevant properties 
          // in the features, and (2) how to get one property and use it
          if (earthquakes.size() &gt; 0) {
              PointFeature f = earthquakes.get(0);
              System.out.println(f.getProperties());
              Object magObj = f.getProperty("magnitude");
              float mag = Float.parseFloat(magObj.toString());
              // PointFeatures also have a getLocation method
          }
  
          // Here is an example of how to use Processing's color method to generate 
          // an int that represents the color yellow.  
          int yellow = color(255, 255, 0);
          int red = color(255, 0, 0);
          int blue = color(0, 0, 255); 
          //TODO: Add code here as appropriate
      }
  
      // A suggested helper method that takes in an earthquake feature and     
      // returns a SimplePointMarker for that earthquake
      // TODO: Implement this method and call it from setUp, if it helps
      private SimplePointMarker createMarker(PointFeature feature)
      {
          //feature.setColor(color(150, 150, 150)); 
  
          // finish implementing and use this method, if it helps.
          return new SimplePointMarker(feature.getLocation());
  
          //earthquakeMarkers = MapUtils.create
      }
  
      public void draw() {
          background(10);
          map.draw();
          addKey();
      }
  
      // helper method to draw key in GUI
      // TODO: Implement this method to draw the key
      private void addKey() 
      {
          // Remember you can use Processing's graphics methods here
          fill(255, 250, 240); //color white
          rect(25, 50, 150, 250); // (x location of upper left corner, y location of upper left corner, width, height)
  
          fill(0); //needed for text to appear, sets the color to fill shapes, takes in an int rgb value
          textAlign(LEFT, CENTER);
          textSize(12);
          text("Earthquake Key", 50, 75); //heading of key, takes (string, float x, and float y)
  
          fill(color(255, 0, 0)); //red
          ellipse(50, 125, 15, 15); //(x coordinate, y coordinate, width, height)   )
          fill(color(255, 255, 0)); //yellow 
          ellipse(50, 175, 10, 10);
          fill(color(0, 0, 255));
          ellipse(50, 225, 5, 5);
  
          fill(0, 0, 0);
          text("5.0+ Magnitude", 75, 125);
          text("4.0+ Magnitude", 75, 175); // same y coordinate but different x so it could appear right beside marker
          text("Below 4.0", 75, 225);
      }
  }
  </code></pre>