Assignment is to build a data visualisation map as per the data seen in the screen shot. However part of the requirements is to allow the user to zoom in by double clicking as well as pan around by dragging the mouse.
This all works, however when panning around it seems to move the actual map object from its describe location. I want to make the map static whilst still having the panning capability. Does anyone have any recommendations for me? I can't seem to figure out anything that works.
Screenshot of app before attempting to pan map:
Screenshot of app after attempting to pan:
Map setup code:
public void setup() {
// (1) Initializing canvas and map tiles
size(displayWidth, displayHeight,OPENGL);
if (offline) {
map = new UnfoldingMap(this, 0, -50, displayWidth, displayHeight, new MBTilesMapProvider(mbTilesString));
//earthquakesURL = "2.5_week.atom"; // The same feed, but saved August 7, 2015
} else {
map = new UnfoldingMap(this, 0, -50, displayWidth, displayHeight, new OpenStreetMap.OpenStreetMapProvider());
// IF YOU WANT TO TEST WITH A LOCAL FILE, uncomment the next line
earthquakesURL = "test2.atom";
}
MapUtils.createDefaultEventDispatcher(this, map);
// (2) Reading in earthquake data and geometric properties
// STEP 1: load country features and markers
List<Feature> countries = GeoJSONReader.loadData(this, countryFile);
countryMarkers = MapUtils.createSimpleMarkers(countries);
// STEP 2: read in city data
List<Feature> cities = GeoJSONReader.loadData(this, cityFile);
cityMarkers = new ArrayList<Marker>();
for (Feature city : cities) {
cityMarkers.add(new CityMarker(city));
}
List<PointFeature> airports = ParseFeed.parseAirports(this, airportFile);
airportMarkers = new ArrayList<Marker>();
for(PointFeature airport : airports) {
AirportMarker m = new AirportMarker(airport);
m.setRadius(15);
airportMarkers.add(m);
}
// STEP 3: read in earthquake RSS feed
List<PointFeature> earthquakes = ParseFeed.parseEarthquake(this, earthquakesURL);
quakeMarkers = new ArrayList<Marker>();
for (PointFeature feature : earthquakes) {
// check if LandQuake
if (isLand(feature)) {
quakeMarkers.add(new LandQuakeMarker(feature));
}
// OceanQuakes
else {
quakeMarkers.add(new OceanQuakeMarker(feature));
}
}
// could be used for debugging
printQuakes();
// (3) Add markers to map
// NOTE: Country markers are not added to the map. They are used
// for their geometric properties
map.addMarkers(quakeMarkers);
map.addMarkers(cityMarkers);
map.addMarkers(airportMarkers);
//map.mapDisplay.resize(mouseX,mouseY);
// Create the buffer to have the information cards display on top of
// map icons
sortAndPrint(10);
} // End setup
public void draw() {
background(0);
map.draw();
addKey();
addFilterBox();
if (lastSelected != null) {
lastSelected.drawTitle(this.g, mouseX, mouseY);
}
//map.mapDisplay.resize(mouseX,mouseY);
}
Additionally, I am aware that Applet has security flaws and in a lot of cases is outdated. However we are being taught the interface in the event we ever run into it in the future. Next project is using javafx, thereafter is Swing, etc.