Example #1
0
  private void bindEvents() {

    searchPresenter
        .getStore()
        .addStoreListener(
            new StoreListener<LocationDTO>() {

              @Override
              public void storeDataChanged(StoreEvent<LocationDTO> event) {
                updateSearchMarkers();
              }
            });
    searchPresenter.addListener(
        Events.Select,
        new Listener<LocationEvent>() {

          @Override
          public void handleEvent(LocationEvent event) {
            if (event.getSource() != LocationMap.this) {
              onLocationSelected(event.getLocation());
            }
          }
        });

    newLocationPresenter.addListener(
        NewLocationPresenter.ACTIVE_STATE_CHANGED,
        new Listener<BaseEvent>() {
          @Override
          public void handleEvent(BaseEvent be) {
            onModeChanged();
          }
        });

    newLocationPresenter.addListener(
        NewLocationPresenter.POSITION_CHANGED,
        new Listener<BaseEvent>() {

          @Override
          public void handleEvent(BaseEvent be) {
            onNewLocationPosChanged();
          }
        });

    newLocationPresenter.addListener(
        NewLocationPresenter.BOUNDS_CHANGED,
        new Listener<BaseEvent>() {

          @Override
          public void handleEvent(BaseEvent be) {
            if (newLocationPresenter.isActive()) {
              LatLngBounds newBounds =
                  LeafletUtil.newLatLngBounds(newLocationPresenter.getBounds());
              map.fitBounds(newBounds);
            }
          }
        });
  }