public void loadData(Envelope envelope, int zoom) { long timeStart = System.currentTimeMillis(); // TODO: use fromInternal(Envelope) here MapPos minPos = projection.fromInternal(envelope.getMinX(), envelope.getMinY()); MapPos maxPos = projection.fromInternal(envelope.getMaxX(), envelope.getMaxY()); String sqlBbox = "" + minPos.x + "," + minPos.y + "," + maxPos.x + "," + maxPos.y; // load geometries List<Geometry> newVisibleElementsList = new LinkedList<Geometry>(); try { Uri.Builder uri = Uri.parse("http://kaart.maakaart.ee/poiexport/roads.php?output=gpoly&").buildUpon(); uri.appendQueryParameter("bbox", sqlBbox); uri.appendQueryParameter("max", String.valueOf(maxObjects)); Log.debug("Vector API url:" + uri.build().toString()); JSONObject jsonData = NetUtils.getJSONFromUrl(uri.build().toString()); if (jsonData == null) { Log.debug("No CartoDB data"); return; } JSONArray rows = jsonData.getJSONArray("res"); for (int i = 0; i < rows.length(); i++) { JSONObject row = rows.getJSONObject(i); String the_geom_encoded = row.getString("g"); String name = row.getString("n"); String type = row.getString("t"); Vector<MapPos> mapPos = GeoUtils.decompress(the_geom_encoded, 5, projection); Geometry newObject = new Line(mapPos, new DefaultLabel(name, type), lineStyleSet, null); newObject.attachToLayer(this); newObject.setActiveStyle(zoom); newVisibleElementsList.add(newObject); } } catch (ParseException e) { Log.error("Error parsing data " + e.toString()); } catch (JSONException e) { Log.error("Error parsing JSON data " + e.toString()); } long timeEnd = System.currentTimeMillis(); Log.debug( "OnlineVector loaded N:" + newVisibleElementsList.size() + " time ms:" + (timeEnd - timeStart)); setVisibleElements(newVisibleElementsList); }