List of usage examples for com.google.gwt.maps.client.geom LatLngBounds isEmpty
public final native boolean isEmpty() ;
true if this rectangle is empty. From source file:org.onebusaway.webapp.gwt.mobile_application.view.MapViewController.java
License:Apache License
public void showStopsForRoute(RouteBean route, StopsForRouteBean stopsForRoute) { _transitMapManager.showStopsForRoute(route, stopsForRoute, true); LatLngBounds b = LatLngBounds.newInstance(); for (StopBean stop : stopsForRoute.getStops()) b.extend(LatLng.newInstance(stop.getLat(), stop.getLon())); if (!b.isEmpty()) { _map.setCenter(b.getCenter(), _map.getBoundsZoomLevel(b)); _locationManager.setLastSearchLocation(b.getCenter()); }/* ww w.j a v a 2 s . c o m*/ }
From source file:org.onebusaway.webapp.gwt.mobile_application.view.MapViewController.java
License:Apache License
public void showPlaces(List<Place> places) { _transitMapManager.showPlaces(places, false, new PlaceClickHandlerImpl(true)); LatLngBounds b = LatLngBounds.newInstance(); for (Place place : places) b.extend(place.getLocation());// ww w . j a v a2 s . co m if (!b.isEmpty()) _locationManager.setLastSearchLocation(b.getCenter()); }
From source file:org.onebusaway.webapp.gwt.oba_application.view.ResultsTablePresenter.java
License:Apache License
private void refresh() { clear();/* ww w . j av a2 s . c o m*/ 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.onebusaway.webapp.gwt.tripplanner_library.view.TripBeanMapPresenter.java
License:Apache License
public void displayTrip(ItineraryBean trip, List<Overlay> resultingOverlays) { resultingOverlays.clear();/*from ww w .j a v a 2s . co m*/ LatLngBounds bounds = LatLngBounds.newInstance(); for (LegBean segment : trip.getLegs()) { String mode = segment.getMode(); if (mode.equals("transit")) { TransitLegBean leg = segment.getTransitLeg(); String path = leg.getPath(); if (path != null) { List<CoordinatePoint> points = PolylineEncoder.decode(path); EncodedPolylineBean bean = PolylineEncoder.createEncodings(points); Polyline line = getPathAsPolyline(bean); PolyStyleOptions style = PolyStyleOptions.newInstance("#0000FF", 4, 0.5); line.setStrokeStyle(style); resultingOverlays.add(line); addBoundsToBounds(line.getBounds(), bounds); } StopBean stop = leg.getFromStop(); if (stop != null) { String routeName = leg.getRouteShortName(); TripPlannerResources resources = TripPlannerResources.INSTANCE; SpanPanel w = new SpanPanel(); w.addStyleName(_css.routeTinyInfoWindow()); Image image = new Image(resources.getBus14x14().getUrl()); image.addStyleName(_css.routeModeIcon()); w.add(image); SpanWidget name = new SpanWidget(routeName); name.setStyleName(_css.routeName()); w.add(name); LatLng point = LatLng.newInstance(stop.getLat(), stop.getLon()); TinyInfoWindowMarker marker = new TinyInfoWindowMarker(point, w); resultingOverlays.add(marker); bounds.extend(point); } } else if (mode.equals("walk")) { List<StreetLegBean> streetLegs = segment.getStreetLegs(); List<CoordinatePoint> allPoints = new ArrayList<CoordinatePoint>(); for (StreetLegBean streetLeg : streetLegs) { String path = streetLeg.getPath(); List<CoordinatePoint> points = PolylineEncoder.decode(path); allPoints.addAll(points); } EncodedPolylineBean polyline = PolylineEncoder.createEncodings(allPoints); Polyline line = getPathAsPolyline(polyline); PolyStyleOptions style = PolyStyleOptions.newInstance("#000000", 4, 0.8); line.setStrokeStyle(style); resultingOverlays.add(line); addBoundsToBounds(line.getBounds(), bounds); } } for (Overlay overlay : resultingOverlays) _map.addOverlay(overlay); if (_centerOnTrip && !bounds.isEmpty()) { _map.setCenter(bounds.getCenter()); int zoom = _map.getBoundsZoomLevel(bounds); _map.setCenter(bounds.getCenter(), zoom); } }
From source file:org.onebusaway.webapp.gwt.tripplanner_library.view.TripBeanMapPresenter.java
License:Apache License
private void addBoundsToBounds(LatLngBounds source, LatLngBounds dest) { if (source == null || source.isEmpty()) { System.out.println("empty bounds"); } else {// w w w. j a va 2 s. c om dest.extend(source.getNorthEast()); dest.extend(source.getSouthWest()); } }
From source file:org.onebusaway.webapp.gwt.where_library.impl.CombinedSearchServiceImpl.java
License:Apache License
@Override public void search(SearchQueryBean query, int placeTimeoutMillis, AsyncCallback<CombinedSearchResult> callback) { LatLngBounds originalBounds = getBounds(query.getBounds()); System.out.println(query.getBounds()); System.out.println(originalBounds); LatLngBounds smallerBounds = null; if (originalBounds != null) { LatLng center = originalBounds.getCenter(); CoordinateBounds cb2 = SphericalGeometryLibrary.bounds(center.getLatitude(), center.getLongitude(), 4000);//ww w .j av a 2s . c o m smallerBounds = getBounds(cb2); System.out.println(cb2); System.out.println(smallerBounds); } CombinedSearchHandlerImpl handler = new CombinedSearchHandlerImpl(originalBounds, placeTimeoutMillis, callback); // Start the route and stop search _service.getRoutesAndStops(query, handler); // Google Maps Geocoder Search Geocoder geocoder = new Geocoder(); if (smallerBounds != null) geocoder.setViewport(smallerBounds); geocoder.getLocations(query.getQuery(), handler); // Google Local Search LocalSearch search = new LocalSearch(); search.setAddressLookupMode(AddressLookupMode.ENABLED); if (!smallerBounds.isEmpty()) search.setCenterPoint(smallerBounds.getCenter()); search.addSearchCompleteHandler(handler); search.execute(query.getQuery()); }
From source file:org.onebusaway.webapp.gwt.where_library.view.stops.TransitMapManager.java
License:Apache License
public void showStopsForRoute(RouteBean route, StopsForRouteBean stopsForRoute, boolean centerViewOnRoute) { reset(false, stopsForRoute.getStops()); _selectedRoute = route;//from w w w . j a v a2s . c o m for (EncodedPolylineBean path : stopsForRoute.getPolylines()) { EncodedPolyline epl = EncodedPolyline.newInstance(path.getPoints(), 32, path.getLevels(3), 4); epl.setColor("#4F64BA"); epl.setWeight(3); epl.setOpacity(1.0); Polyline polyline = Polyline.fromEncoded(epl); _manager.addOverlay(polyline); _otherOverlays.add(polyline); } if (centerViewOnRoute) { System.out.println("center on route"); // Center the map on the bounds of the route LatLngBounds bounds = LatLngBounds.newInstance(); for (StopBean stop : stopsForRoute.getStops()) bounds.extend(LatLng.newInstance(stop.getLat(), stop.getLon())); if (!bounds.isEmpty()) { int zoomLevel = _map.getBoundsZoomLevel(bounds); _map.setCenter(bounds.getCenter(), zoomLevel); } } }
From source file:org.onebusaway.webapp.gwt.where_library.view.stops.TransitMapManager.java
License:Apache License
public void showPlaces(List<Place> places, boolean showStopsInCurrentView, PlaceClickHandler clickHandler) { LatLngBounds bounds = LatLngBounds.newInstance(); for (Place place : places) bounds.extend(place.getLocation()); if (!bounds.isEmpty()) _map.setCenter(bounds.getCenter(), _map.getBoundsZoomLevel(bounds)); reset(showStopsInCurrentView);/*w ww. j a v a 2 s . com*/ for (Place place : places) addPlaceToMap(place, clickHandler); }