Hi,
This sounds like it should be pretty easy, but it's been giving me trouble. I'm trying create circles around many points (from a parsed .json file) onto a mask which is then applied to an unfolding map. The trouble is that I can't figure out how to draw more than one circle at a time on the mask. I have tried to do it with an array, but when I convert the lat/ lon coordinates into x/y coordinates with getScreenPositionFromLocation(); (line 53) and then split them into x and y coordinates, I'm not able to get the screen positions as an array.
This is probably a pretty easy fix, but I'm really stuck. Any help would be appreciated.
Thanks
seanmp
- import org.json.*;
- import processing.opengl.*;
- import codeanticode.glgraphics.*;
- import de.fhpotsdam.unfolding.*;
- import de.fhpotsdam.unfolding.geo.*;
- import de.fhpotsdam.unfolding.utils.*;
- import de.fhpotsdam.unfolding.providers.*;
- import de.fhpotsdam.unfolding.mapdisplay.MapDisplayFactory;
- import de.fhpotsdam.unfolding.Map;
- Map map1;
- Map map2;
- PGraphics topLayer, pg;
- PImage mapimg;
- int circleSize = 80;
- float[] lats;
- float[] lons;
- void setup() {
- size(600, 600, P2D);
- background(0, 50, 0);
- map1 = new de.fhpotsdam.unfolding.Map(this, "map1", 0, 0, width, height, true, false, new Microsoft.AerialProvider());
- map1.setTweening(false);
- map2 = new de.fhpotsdam.unfolding.Map(this, "map2", 0, 0, width, height, true, false, //size of the map window
- new OpenStreetMap.CloudmadeProvider(MapDisplayFactory.OSM_API_KEY, 41315)); //for cloudmade, need api key and map #
- map2.setTweening(false);
- MapUtils.createDefaultEventDispatcher(this, map1, map2);
- lats =new float[414];
- lons =new float[414];
- topLayer = createGraphics(width, height, P2D);
- }
- void draw() {
- PGraphics pg = map1.mapDisplay.getPG();
- map1.draw();
- map2.draw();
- topLayer.beginDraw();
- try {
- JSONObject waypointList = new JSONObject(join(loadStrings("get_gps_detail.json"), ""));
- JSONArray gps = waypointList.getJSONArray("waypointList");
- for (int i = 0; i < gps.length(); i++) {
- JSONObject value = gps.getJSONObject(i);
- float floatlat = (float)value.getDouble("lat");
- float floatlon = (float)value.getDouble("lon");
- lats[i] = floatlat;
- lons[i] = floatlon;
- Location manyloc = new Location(lats[i], lons[i]); //where the trouble starts
- float xy[]=map1.getScreenPositionFromLocation(manyloc);
- topLayer.background(255);
- topLayer.noStroke();
- topLayer.fill(50);
- topLayer.ellipse(xy[0], xy[1], circleSize, circleSize);
- }
- }
- catch (JSONException v) {
- }
- topLayer.endDraw();
- mapimg = pg.get(0, 0, width, height);
- mapimg.mask(topLayer);
- image(mapimg, 0, 0);
- }
1