List of usage examples for com.google.gwt.maps.client.geom LatLngBounds containsBounds
public final native boolean containsBounds(LatLngBounds other) ;
true if the passed rectangle is contained within this rectangle. From source file:org.onebusaway.webapp.gwt.oba_application.view.ResultsTablePresenter.java
License:Apache License
private void refresh() { clear();// www. j a v a2 s . com if (_minimized) { DivPanel panel = new DivPanel(); panel.addStyleName(_css.ResultsTableWidgetMinimized()); _tablePanel.add(panel); Anchor showAllEntries = new Anchor("Show all results..."); showAllEntries.addClickHandler(new ClickHandler() { public void onClick(ClickEvent arg0) { _control.clearActiveSearchResult(); } }); panel.add(showAllEntries); constructAttributionPanel(); } else { _tablePanel.add(_filterWidget); List<TimedLocalSearchResult> entries = _model.getActiveEntries(); Grid grid = new Grid(entries.size() + 1, 4); grid.addStyleName(_css.ResultsTableWidgetResultsTable()); grid.setText(0, 0, ""); grid.setWidget(0, 1, getTableHeaderWidget("Name", EResultsSort.NAME)); grid.setWidget(0, 2, getTableHeaderWidget("Rating", EResultsSort.RATING)); grid.setWidget(0, 3, getTableHeaderWidget("Distance", EResultsSort.DISTANCE)); grid.getRowFormatter().addStyleName(0, "ResultsTableWidget-ResultsTable-HeaderRow"); grid.getCellFormatter().addStyleName(0, 1, "ResultsTableWidget-ResultsTable-HeaderRow-Name"); grid.getCellFormatter().addStyleName(0, 2, "ResultsTableWidget-ResultsTable-HeaderRow-Rating"); grid.getCellFormatter().addStyleName(0, 3, "ResultsTableWidget-ResultsTable-HeaderRow-Distance"); int index = 0; LatLngBounds bounds = LatLngBounds.newInstance(); for (TimedLocalSearchResult tlsr : entries) { LocalSearchResult entry = tlsr.getLocalSearchResult(); int tableRow = index + 1; EntryClickHandler handler = new EntryClickHandler(tlsr); String labelPre = index < ROW_LABELS.length() ? (ROW_LABELS.charAt(index) + "") : ""; grid.setWidget(tableRow, 0, new SpanWidget(labelPre)); grid.getCellFormatter().addStyleName(tableRow, 0, "ResultsTableWidget-ResultsTable-LabelColumn"); Anchor name = new Anchor(entry.getName()); name.addClickHandler(handler); grid.setWidget(tableRow, 1, name); grid.getCellFormatter().addStyleName(tableRow, 1, "ResultsTableWidget-ResultsTable-NameColumn"); if (entry.getRatingUrlSmall() != null) { Image image = new Image(entry.getRatingUrlSmall()); grid.setWidget(tableRow, 2, image); } else { String rating = entry.getRating() + "/" + entry.getMaxRating(); grid.setText(tableRow, 2, rating); } grid.getCellFormatter().addStyleName(tableRow, 2, "ResultsTableWidget-ResultsTable-RatingColumn"); int minutes = tlsr.getTime() / 60; String minLabel = minutes + " " + (minutes == 1 ? " min" : " mins"); grid.setText(tableRow, 3, minLabel); grid.getCellFormatter().addStyleName(tableRow, 3, "ResultsTableWidget-ResultsTable-TimeColumn"); grid.getRowFormatter().addStyleName(tableRow, "ResultsTableWidget-ResultsTable-ResultRow"); Marker marker = getMarker(index, entry); marker.addMarkerClickHandler(handler); _mapOverlayManager.addOverlay(marker, 10, 20); _overlays.add(marker); index++; bounds.extend(marker.getLatLng()); } if (!bounds.isEmpty()) { MapWidget map = _mapOverlayManager.getMapWidget(); LatLngBounds currentView = map.getBounds(); if (!currentView.containsBounds(bounds)) { _mapOverlayManager.setCenterAndZoom(bounds); } } _tablePanel.add(grid); constructItemNavigationPanel(entries); constructAttributionPanel(); } }
From source file:org.sigmah.client.page.entry.SiteMap.java
License:Open Source License
private void onSiteSelected(SiteEvent se) { if (se.getSource() != this) { if (se.getEntity() != null && !se.getEntity().hasCoords()) { BoundingBoxDTO bounds = AdminBoundsHelper.calculate(country, se.getEntity()); LatLngBounds llBounds = llBoundsForBounds(bounds); if (!llBounds.containsBounds(map.getBounds())) { zoomToBounds(llBounds);/*from w ww. j av a2 s .c o m*/ } } else { highlightSite(se.getSiteId(), true); } } }