Example usage for com.google.gwt.search.client AddressLookupMode ENABLED

List of usage examples for com.google.gwt.search.client AddressLookupMode ENABLED

Introduction

In this page you can find the example usage for com.google.gwt.search.client AddressLookupMode ENABLED.

Prototype

AddressLookupMode ENABLED

To view the source code for com.google.gwt.search.client AddressLookupMode ENABLED.

Click Source Link

Document

Enables resolving addresses.

Usage

From source file:com.google.mobile.trippy.web.client.db.DefaultSearchService.java

License:Apache License

/**
 * Google search related methods//  w  ww  . ja  v a  2 s.  com
 */
private void doGoogleSearch(final String queryString, final HasLatLngBounds searchBounds,
        final String tripLocation, final SearchResultsListener listener) {

    googleSearchService.clearResults();
    googleSearchService.setNoHtmlGeneration();
    googleSearchService.setResultSetSize(ResultSetSize.LARGE);
    //    googleSearchService.setCenterPoint(searchBounds.getCenter().getJso());
    googleSearchService.setAddressLookupMode(AddressLookupMode.ENABLED);
    googleSearchService.setCenterPoint(tripLocation);

    final List<SearchItem> searchItemList = new ArrayList<SearchItem>();
    googleSearchService.addSearchResultsHandler(new SearchResultsHandler() {

        @SuppressWarnings("unchecked")
        @Override
        public void onSearchResults(SearchResultsEvent event) {
            JsArray<LocalResult> results = event.getResults().cast();
            if (results == null || results.length() == 0) {
                searchItemList.clear();
                listener.onSuccess(searchItemList);
                return;
            }
            addGoogleResultsToList(queryString, searchBounds, searchItemList, results);

            // for more than one page.
            final Cursor resultCursor = googleSearchService.getCursor();
            if (resultCursor != null) {
                int currentPage = resultCursor.getCurrentPageIndex();
                int totalPages = resultCursor.getPages().length();
                if (currentPage < totalPages - 1 && currentPage < MAX_GOOGLE_SEARCH_RESULTS_PAGE) {
                    googleSearchService.gotoPage(++currentPage);
                } else {
                    // Trippy-enforced page limit reached
                    searchResultsCache.put(getResultsCacheKey(SearchType.GOOGLE, queryString, searchBounds),
                            searchItemList);
                    listener.onSuccess(searchItemList);
                }
            } else {
                // No more results if cursor is null.
                searchResultsCache.put(getResultsCacheKey(SearchType.GOOGLE, queryString, searchBounds),
                        searchItemList);
                listener.onSuccess(searchItemList);
            }
        }
    });

    googleSearchService.execute(queryString);
}

From source file:org.onebusaway.webapp.gwt.common.control.PlaceSearch.java

License:Apache License

public void query(String query, PlaceSearchListener listener, LatLngBounds view) {

    final LocationHandler handler = new LocationHandler(listener, view);

    // Google Local Search
    LocalSearch search = new LocalSearch();

    search.setAddressLookupMode(AddressLookupMode.ENABLED);
    if (view != null)
        search.setCenterPoint(view.getCenter());
    search.addSearchCompleteHandler(handler);
    search.execute(query);//from   w  w  w. j  a v  a  2  s.  c  o  m

    // Google Maps Geocoder Search
    Geocoder geocoder = new Geocoder();
    if (view != null)
        geocoder.setViewport(view);
    geocoder.getLocations(query, handler);

    handler.scheduleRepeating(1000);
}

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;/* w w  w  .j  a v a 2 s .  c  o  m*/
    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());
}