I'm trying to put a bunch of markers on an unfolding map in Processing after loading them in from a URL. I've checked and there's definitely locations being created, but the markers aren't being drawn on the map. Here's code:
theMap = new UnfoldingMap(this, 0, 10, 540, 580); theMap.setTweening(true); Location England = new Location(54.5f, -2.7f); theMap.zoomAndPanTo(5, England); float maxPanningDistance = 350; // in km theMap.setPanningRestriction(England, maxPanningDistance); EventDispatcher eventDispatcher = new EventDispatcher(); MouseHandler mouseHandler = new MouseHandler(this, theMap); eventDispatcher.addBroadcaster(mouseHandler); MapUtils.createDefaultEventDispatcher(this, theMap);
postcodeList = new ArrayList (); for (int i = 0; i < propertyList.size(); i++) { Data data = propertyList.get(i); postcodeList.add(data.list[2]); }
json = new JSONObject();
for (int i = 0; i < postcodeList.size(); i++)
{
postCode = postcodeList.get(i);
postCode = postCode.replaceAll("\s", "");
try {
url = new URL("https://api.postcodes.io/postcodes/" + postCode);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int responseCode = connection.getResponseCode();
if (responseCode == 200)
{
json = loadJSONObject ("https://api.postcodes.io/postcodes/" + postCode);
JSONObject result = json.getJSONObject ("result");
float longitude = (float) result.getFloat ("longitude");
float latitude = (float) result.getFloat ("latitude");
Location location = new Location (longitude, latitude);
SimplePointMarker Marker = new SimplePointMarker(location);
theMap.addMarker(Marker);
}
}
catch (Exception exception) {
}
}
Does anyone have any ideas?