Skip to content

Instantly share code, notes, and snippets.

@PDXIII
Created April 15, 2013 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PDXIII/5387504 to your computer and use it in GitHub Desktop.
Save PDXIII/5387504 to your computer and use it in GitHub Desktop.
Code snippet for my Unfolding tutorial site.
ArrayList <ArrayList> makeAirportLists(
UnfoldingMap map,
List<Marker> countryMarkers,
List<Marker> airportMarkers){
ArrayList <ArrayList> lists = new ArrayList();
// iterating through the countryMarkers
for (Marker country : countryMarkers){
// a new ArrayList for each country
ArrayList currentMarkerList = new ArrayList();
// iterating through the airportMarkers
for (Marker airport : airportMarkers){
// we need to get the Loction of the airport
Location airportLocation = airport.getLocation();
// we need do convert it into a ScreenPosition
ScreenPosition airportScreenPos = map.getScreenPosition(airportLocation);
// and if this ScreenPosition is inside the country
if(country.isInside(map, airportScreenPos.x, airportScreenPos.y)){
// we add the Marker to this ArrayList
currentMarkerList.add(airport);
}
}
// we add this ArrayList of Markers to our ArrayList of ArrayLists
lists.add(currentMarkerList);
// to see if the program is running we generate some output
println(lists.size());
}
airportListsBuild = true;
return lists;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment