private void selectMarkerIfClicked(List<Marker> markers) { for (Marker marker : markers) { if (marker.isInside(map, mouseX, mouseY)) { marker.setSelected(true); lastClicked = (CommonMarker) marker; break; } } }
// If there was a marker underneath the mouse when it was clicked // it's clicked property is set to true // returns true if the marker was found underneath it private boolean clickMarkerIfClicked(List<Marker> markers, float x, float y) { for (Marker marker : markers) { if (marker.isInside(map, x, y)) { lastClicked = (CommonMarker) marker; lastClicked.setClicked(true); return true; } } return false; }
// If there is a marker under the cursor, and lastSelected is null // set the lastSelected to be the first marker found under the cursor // Make sure you do not select two markers. // private void selectMarkerIfHover(List<Marker> markers) { // Select the marker and call it's setSelected() method with first argument as true for (Marker marker : markers) { if (marker.isInside(map, mouseX, mouseY)) { lastSelected = (CommonMarker) marker; lastSelected.setSelected(true); break; } } }
// If there is a marker under the cursor, and lastSelected is null // set the lastSelected to be the first marker found under the cursor // Make sure you do not select two markers. // private void selectMarkerIfHover(List<Marker> markers) { // TODO: Implement this method for (Marker marker : markers) { if (marker.isInside(map, mouseX, mouseY)) { marker.setSelected(true); lastSelected = (CommonMarker) marker; break; } } }
// If there is a marker under the cursor, and lastSelected is null // set the lastSelected to be the first marker found under the cursor // Make sure you do not select two markers. // private void selectMarkerIfHover(List<Marker> markers) { // TODO: Implement this method if (lastSelected != null) return; for (Marker marker : markers) { if (marker.isInside(map, mouseX, mouseY)) { lastSelected = (CommonMarker) marker; lastSelected.setSelected(true); return; } } }
// Helper method that will check if a city marker was clicked on // and respond appropriately private void checkCitiesForClick() { if (lastClicked != null) return; // Loop over the earthquake markers to see if one of them is selected for (Marker marker : cityMarkers) { if (!marker.isHidden() && marker.isInside(map, mouseX, mouseY)) { lastClicked = (CommonMarker) marker; // Hide all the other earthquakes and hide for (Marker mhide : cityMarkers) if (mhide != lastClicked) mhide.setHidden(true); for (Marker mhide : quakeMarkers) { EarthquakeMarker quakeMarker = (EarthquakeMarker) mhide; if (quakeMarker.getDistanceTo(marker.getLocation()) > quakeMarker.threatCircle()) quakeMarker.setHidden(true); } return; } } }