public void handleUpdate(TimedRegionModel model) { clear(); double maxTime = model.getMaxTime(); LatLngBounds bounds = LatLngBounds.newInstance(); for (TimedRegion region : model.getRegions()) { String color = getColorForTime(region.getTime(), maxTime); LatLngBounds regionBounds = region.getBounds(); PatchMarker marker = new PatchMarker(regionBounds); Style style = marker.getStyle(); style.setProperty("backgroundColor", color); marker.addStyleName("patch"); // _overlays.add(marker); _mapOverlayManager.addOverlay(marker, 10, 15); bounds.extend(regionBounds.getNorthEast()); bounds.extend(regionBounds.getSouthWest()); } if (!bounds.isEmpty()) { MapWidget map = _mapOverlayManager.getMapWidget(); int zoom = map.getBoundsZoomLevel(bounds); map.setCenter(bounds.getCenter(), zoom); } }
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; }
public void handleUpdate(TimedPolygonModel model) { clear(); LatLngBounds bounds = LatLngBounds.newInstance(); double maxTime = model.getMaxTime(); for (TimedPolygon tp : model.getPolygons()) { Polygon poly = tp.getPolyline(); String color = getColorForTime(tp.getTime(), maxTime); double opacity = getOpacityForTime(tp.getTime(), maxTime); poly.setFillStyle(PolyStyleOptions.newInstance(color, 1, opacity)); poly.setStrokeStyle(PolyStyleOptions.newInstance(color, 1, opacity)); _mapOverlayManager.addOverlay(poly); _overlays.add(poly); LatLngBounds b = poly.getBounds(); bounds.extend(b.getNorthEast()); bounds.extend(b.getSouthWest()); } if (!bounds.isEmpty()) { MapWidget map = _mapOverlayManager.getMapWidget(); if (model.isComplete()) { int zoom = map.getBoundsZoomLevel(bounds); map.setCenter(bounds.getCenter(), zoom); List<String> colors = new ArrayList<String>(); for (int i = 0; i <= 6; i++) { double ratio = i / 6.0; colors.add(_colormap.getColor(ratio)); } String fromLabel = "0 mins"; String toLabel = model.getMaxTime() + " mins"; _colorGradientControl.setGradient(colors, fromLabel, toLabel); } else { map.setCenter(_queryModel.getLocation()); } } }