Package com.google.gwt.maps.client.geom

Examples of com.google.gwt.maps.client.geom.LatLngBounds


      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);
View Full Code Here


      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);
View Full Code Here

  @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);
      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());
  }
View Full Code Here

    search.execute(query.getQuery());
  }

  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()));
    }

    return b;
  }
View Full Code Here

    }

    @Override
    public void onSuccess(List<AgencyWithCoverageBean> agencies) {

      LatLngBounds bounds = LatLngBounds.newInstance();
      for (AgencyWithCoverageBean agencyWithCoverage : agencies) {

        final AgencyBean agency = agencyWithCoverage.getAgency();
        final LatLng point = LatLng.newInstance(agencyWithCoverage.getLat(),
            agencyWithCoverage.getLon());
        bounds.extend(point);

        Marker marker = new Marker(point);
        marker.addMarkerClickHandler(new MarkerClickHandler() {
          @Override
          public void onClick(MarkerClickEvent event) {
            InfoWindow window = _map.getInfoWindow();
            DivPanel panel = new DivPanel();

            DivPanel rowA = new DivPanel(_css.paragraph());
            panel.add(rowA);
            rowA.add(new Anchor(agency.getName(), agency.getUrl()));

            DivPanel rowB = new DivPanel(_css.paragraph());
            panel.add(rowB);
            rowB.add(new Anchor("jump to map", "index.html#m(location)lat("
                + point.getLatitude() + ")lon(" + point.getLongitude()
                + ")accuracy(4)"));
            window.open(point, new InfoWindowContent(panel));
          }
        });

        _map.addOverlay(marker);
      }

      if (!bounds.isEmpty())
        _map.setCenter(bounds.getCenter(), _map.getBoundsZoomLevel(bounds)-1);
    }
View Full Code Here

    if (includeView) {
      MapWidget map = _widget.getMapWidget();

      LatLng center = map.getCenter();

      LatLngBounds bounds = map.getBounds();
      LatLng ne = bounds.getNorthEast();
      LatLng sw = bounds.getSouthWest();
      double latSpan = Math.abs(ne.getLatitude() - sw.getLatitude());
      double lonSpan = Math.abs(ne.getLongitude() - sw.getLongitude());

      addBoundsToParams(m, center.getLatitude(), center.getLongitude(),
          latSpan, lonSpan);
View Full Code Here

    try {
      double latRadius = Double.parseDouble(tokens[0]) / 2;
      double lonRadius = Double.parseDouble(tokens[1]) / 2;

      LatLngBounds bounds = LatLngBounds.newInstance();
      bounds.extend(LatLng.newInstance(center.getLatitude() + latRadius,
          center.getLongitude() + lonRadius));
      bounds.extend(LatLng.newInstance(center.getLatitude() - latRadius,
          center.getLongitude() - lonRadius));

      MapWidget map = _widget.getMapWidget();
      return map.getBoundsZoomLevel(bounds);
    } catch (NumberFormatException ex) {
View Full Code Here

       
        CoordinateBounds b = _config.getBounds();
       
        LatLng from = LatLng.newInstance(b.getMinLat(), b.getMinLon());
        LatLng to = LatLng.newInstance(b.getMaxLat(), b.getMaxLon());
        LatLngBounds bounds = LatLngBounds.newInstance(from, to);
       
        int zoom = _map.getBoundsZoomLevel(bounds);
       
        System.out.println(bounds + " => " + zoom);
        _map.setZoomLevel(zoom);
View Full Code Here

  public void displayTrip(ItineraryBean trip, List<Overlay> resultingOverlays) {

    resultingOverlays.clear();

    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);
    }
  }
View Full Code Here

  private void refreshView() {
    _overlayManager.clear();
    if (_map.getZoomLevel() < 16)
      return;
    LatLngBounds llBounds = _map.getBounds();
    LatLng a = llBounds.getNorthEast();
    LatLng b = llBounds.getSouthWest();
    CoordinateBounds bounds = new CoordinateBounds(a.getLatitude(),
        a.getLongitude(), b.getLatitude(), b.getLongitude());

    TripsForBoundsQueryBean query = new TripsForBoundsQueryBean();
    query.setBounds(bounds);
View Full Code Here

TOP

Related Classes of com.google.gwt.maps.client.geom.LatLngBounds

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.