private void updateSearchMarkers() { markerLayer.clearLayers(); List<LocationDTO> locations = Lists.reverse(searchPresenter.getStore().getModels()); LatLngBounds bounds = new LatLngBounds(); boolean empty = true; for (LocationDTO location : locations) { if (location.hasCoordinates()) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); Marker marker = createMarker(latLng, location.getMarker()); markerLayer.addLayer(marker); bounds.extend(latLng); bindClickEvent(location, marker); empty = false; } } if (empty) { if (searchPresenter.getBounds() != null) { bounds = LeafletUtil.newLatLngBounds(searchPresenter.getBounds()); } else { bounds = LeafletUtil.newLatLngBounds(searchPresenter.getCountry().getBounds()); } } int effectiveZoom = Math.min(8, map.getBoundsZoom(bounds, false)); map.setView(bounds.getCenter(), effectiveZoom, false); map.fitBounds(bounds); }