Example #1
0
 private MapPosition getUserLocationPosition() {
   GeoPoint point = getUserLocationPoint();
   MapPosition mapPosition =
       new MapPosition(point.getLatitude(), point.getLongitude(), mapController.getZoomScale());
   mapPosition.setBearing(mapController.getMapPosition().getBearing());
   mapPosition.setTilt(mapController.getMapPosition().getTilt());
   return mapPosition;
 }
Example #2
0
 private void teardownLinedrawing() {
   mapController.getMap().events.unbind(mapListener);
   if (activeTask != null) {
     activeTask.cancel(true);
   }
   mapController.clearLines();
   mapFragment.updateMap();
 }
Example #3
0
  public void findMe() {
    if (mapController.getLocation() != null) {
      addLocationDot();
      if (followMe || !initialRelocateHappened) {
        // TODO find ways to accomplish this without two flags ;(
        mapController.resetMapForUser();
        initialRelocateHappened = true;
        getMap().setMapPosition(getUserLocationPosition());
      }

      updateMap();
    }
  }
Example #4
0
 private void manageMap(Location originalLocation, Location location) {
   if (location != null) {
     zoomController.setAverageSpeed(getAverageSpeed());
     zoomController.setCurrentSpeed(originalLocation.getSpeed());
     if (isPaging) {
       mapController.setZoomLevel(zoomController.getZoom());
       mapController.quarterOn(location, route.getCurrentRotationBearing());
     }
     routeLocationIndicator.setRotation((float) route.getCurrentRotationBearing());
     routeLocationIndicator.setPosition(location.getLatitude(), location.getLongitude());
     mapFragment.updateMap();
   }
 }
 @Test
 public void success_shouldAddMarkerLayerOnce() throws Exception {
   fragment.createRouteToDestination();
   fragment.success(new Route(getFixture("around_the_block")));
   fragment.success(new Route(getFixture("around_the_block")));
   assertThat(mapController.getMap().layers().contains(fragment.markers)).isTrue();
 }
 @Test
 public void onDetach_shouldRemovePath() throws Exception {
   fragment.createRouteToDestination();
   Route testRoute = new Route(getFixture("around_the_block"));
   fragment.success(testRoute);
   fragment.onDetach();
   assertThat(mapController.getMap().layers().contains(fragment.path)).isFalse();
 }
 @Test
 public void start_shouldClearBubbles() throws Exception {
   fragment.createRouteToDestination();
   Route testRoute = new Route(getFixture("around_the_block"));
   fragment.success(testRoute);
   fragment.routingCircle.performClick();
   assertThat(mapController.getMap().layers().contains(fragment.markers)).isFalse();
 }
Example #8
0
 @Override
 public void onResume() {
   super.onResume();
   inject();
   mapController.restoreFromSavedLocation();
   registerLocationReceivers();
   poiMarkersLayer.repopulate();
 }
Example #9
0
 @Override
 public void onPause() {
   super.onPause();
   mapController.saveLocation();
   locationMarkerLayer.removeAllItems();
   poiMarkersLayer.removeAllItems();
   unregisterLocationReceivers();
 }
 @Test
 public void reverse_shouldGetFeatureDestinationFirst() throws Exception {
   mapController.setLocation(getTestLocation(22.22, 44.44));
   fragment.reverse();
   verify(router, times(4)).setLocation(location.capture());
   List<double[]> values = location.getAllValues();
   assertThat(values.get(2)).isEqualTo(new double[] {1.0, 1.0});
   assertThat(values.get(3)).isEqualTo(new double[] {22.22, 44.44});
 }
Example #11
0
 @Override
 public void onPageSelected(int i) {
   if (!isPaging) {
     mapController.setMapPerspectiveForInstruction(instructions.get(i));
   } else {
     setCurrentPagerItemStyling(i);
   }
   notificationCreator.createNewNotification(
       SimpleFeatureHelper.getMarker(simpleFeature).title,
       instructions.get(i).getFullInstruction(getActivity()));
 }
Example #12
0
 public boolean setRoute(final Route route) {
   if (route != null && route.foundRoute()) {
     this.route = route;
     this.instructions = route.getRouteInstructions();
     storeRouteInDatabase(route.getRawRoute());
     mapController.setMapPerspectiveForInstruction(instructions.get(0));
     routeEngine.setRoute(route);
     routeEngine.setListener(this);
   } else {
     return false;
   }
   return true;
 }
Example #13
0
  @Override
  public void onDestroy() {
    app.activateMoveMapToLocation();
    teardownLinedrawing();
    markReadyForUpload();
    mapController.clearLines();
    act.updateView();

    bus.unregister(this);
    showLocateButton();
    if (LocationServices.FusedLocationApi != null) {
      LocationServices.FusedLocationApi.setMockMode(false);
    }
    super.onDestroy();
  }
Example #14
0
 public void createRouteTo(Location location) {
   mapController.clearLines();
   mapFragment.clearMarkers();
   mapFragment.updateMap();
   isRouting = true;
   act.showLoadingIndicator();
   router
       .clearLocations()
       .setLocation(locationToPair(location))
       // To allow routing to see which direction you are travelling
       .setLocation(
           locationToPair(
               getDistancePointFromBearing(location, 15, (int) Math.floor(location.getBearing()))))
       .setLocation(geoPointToPair(SimpleFeatureHelper.getGeoPoint(simpleFeature)))
       .setCallback(this)
       .fetch();
 }
Example #15
0
 @Provides
 @Singleton
 MapController provideMapController() {
   return MapController.getMapController();
 }
Example #16
0
 private void setupLinedrawing() {
   mapController.getMap().events.bind(mapListener);
 }
Example #17
0
 public GeoPoint getUserLocationPoint() {
   Location userLocation = mapController.getLocation();
   return new GeoPoint(userLocation.getLatitude(), userLocation.getLongitude());
 }
Example #18
0
 private void setPerspectiveForCurrentInstruction() {
   int current = pagerPositionWhenPaused > 0 ? pagerPositionWhenPaused - 1 : 0;
   mapController.setMapPerspectiveForInstruction(instructions.get(current));
 }