List of usage examples for com.google.gwt.maps.client.geom LatLngBounds extend
public final native void extend(LatLng coordinate) ;
From source file:es.upm.fi.dia.oeg.map4rdf.client.view.v2.GoogleMapLayer.java
License:Open Source License
@Override public HasClickHandlers drawCircle(StyleMapShape<Circle> circle) { LatLngBounds bounds = LatLngBounds.newInstance(); LatLng[] circlePoints = new LatLng[CIRCLE_NUMBER_OF_POINTS]; double EARTH_RADIUS = 6371000; double d = circle.getMapShape().getRadius() / EARTH_RADIUS; double lat1 = Math.toRadians(circle.getMapShape().getCenter().getY()); double lng1 = Math.toRadians(circle.getMapShape().getCenter().getX()); double a = 0; double step = 360.0 / CIRCLE_NUMBER_OF_POINTS; for (int i = 0; i < CIRCLE_NUMBER_OF_POINTS; i++) { double tc = Math.toRadians(a); double lat2 = Math.asin(Math.sin(lat1) * Math.cos(d) + Math.cos(lat1) * Math.sin(d) * Math.cos(tc)); double lng2 = lng1 + Math.atan2(Math.sin(tc) * Math.sin(d) * Math.cos(lat1), Math.cos(d) - Math.sin(lat1) * Math.sin(lat2)); LatLng point = LatLng.newInstance(Math.toDegrees(lat2), Math.toDegrees(lng2)); circlePoints[i] = point;//w ww .j ava2 s .com bounds.extend(point); a += step; } com.google.gwt.maps.client.overlay.Polygon polygon = new com.google.gwt.maps.client.overlay.Polygon( circlePoints, circle.getStrokeColor(), circle.getStrokeWidth(), circle.getStrokeOpacity(), circle.getFillColor(), circle.getFillOpacity()); addOverlay(polygon); return new PolygonClickHandlerWrapper(polygon); }
From source file:es.upm.fi.dia.oeg.map4rdf.client.widget.mapcontrol.StatisticsMapControl.java
License:Open Source License
private void drawCircleFromRadius(LatLng center, double radius, int nbOfPoints) { LatLngBounds bounds = LatLngBounds.newInstance(); LatLng[] circlePoints = new LatLng[nbOfPoints]; double EARTH_RADIUS = 6371000; double d = radius / EARTH_RADIUS; double lat1 = Math.toRadians(center.getLatitude()); double lng1 = Math.toRadians(center.getLongitude()); double a = 0; double step = 360.0 / nbOfPoints; for (int i = 0; i < nbOfPoints; i++) { double tc = Math.toRadians(a); double lat2 = Math.asin(Math.sin(lat1) * Math.cos(d) + Math.cos(lat1) * Math.sin(d) * Math.cos(tc)); double lng2 = lng1 + Math.atan2(Math.sin(tc) * Math.sin(d) * Math.cos(lat1), Math.cos(d) - Math.sin(lat1) * Math.sin(lat2)); LatLng point = LatLng.newInstance(Math.toDegrees(lat2), Math.toDegrees(lng2)); circlePoints[i] = point;/*from w w w . j a v a2 s .co m*/ bounds.extend(point); a += step; } Polygon circle = new Polygon(circlePoints, "white", 0, 0, "green", 0.4); addOverlay(circle); }
From source file:org.onebusaway.webapp.gwt.mobile_application.control.Actions.java
License:Apache License
private static LatLngBounds getSearchBoundsAsLatLngBounds(double radius) { CoordinateBounds bounds = getSearchBounds(radius); LatLngBounds b = LatLngBounds.newInstance(); b.extend(LatLng.newInstance(bounds.getMinLat(), bounds.getMinLon())); b.extend(LatLng.newInstance(bounds.getMaxLat(), bounds.getMaxLon())); return b;/* 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 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()); }//from w w w .ja va 2s. c om }
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()); 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();//from ww w . j av a 2 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.oba_library.model.TimedRegionModel.java
License:Apache License
public void setData(List<CoordinateBounds> timeGrid, List<Integer> times) { _bounds = LatLngBounds.newInstance(); _regions.clear();/*from www.j a v a2 s .c o m*/ _maxTime = 0; for (int i = 0; i < timeGrid.size(); i++) { CoordinateBounds bounds = timeGrid.get(i); int time = times.get(i); _maxTime = Math.max(time, _maxTime); LatLng p1 = LatLng.newInstance(bounds.getMinLat(), bounds.getMinLon()); LatLng p2 = LatLng.newInstance(bounds.getMaxLon(), bounds.getMaxLon()); LatLngBounds b = LatLngBounds.newInstance(); b.extend(p1); b.extend(p2); TimedRegion region = new TimedRegion(b, time); _regions.add(region); _bounds.extend(p1); _bounds.extend(p2); } refresh(); }
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 w ww . j ava 2 s . c o 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 v a 2 s . c o m*/ dest.extend(source.getNorthEast()); dest.extend(source.getSouthWest()); } }
From source file:org.onebusaway.webapp.gwt.where_library.impl.CombinedSearchServiceImpl.java
License:Apache License
private LatLngBounds getBounds(CoordinateBounds bounds) { LatLngBounds b = LatLngBounds.newInstance(); if (bounds != null) { b.extend(LatLng.newInstance(bounds.getMinLat(), bounds.getMinLon())); b.extend(LatLng.newInstance(bounds.getMaxLat(), bounds.getMaxLon())); }/* www. j a va 2s . c o m*/ return b; }