Пример #1
0
 /**
  * Removes the stop focus and notify listener
  *
  * @param latLng the location on the map where the user tapped if the focus change was triggered
  *     by the user tapping on the map, or null if the focus change was otherwise triggered
  *     programmatically.
  */
 private void removeFocus(LatLng latLng) {
   if (mMarkerData.getFocus() != null) {
     mMarkerData.removeFocus();
   }
   // Set map clicked location, if it exists
   Location location = null;
   if (latLng != null) {
     location = MapHelpV2.makeLocation(latLng);
   }
   // Notify focus changed every time the map is clicked away from a stop marker
   mOnFocusChangedListener.onFocusChanged(null, null, location);
 }
 /**
  * Update an existing marker on the map with the current vehicle status
  *
  * @param m Marker to update
  * @param l Location to add the marker at
  * @param isRealtime true if the marker shown indicate real-time info, false if it should
  *     indicate schedule
  * @param status real-time status of the vehicle
  * @param response response containing the provided status
  */
 private void updateMarker(
     Marker m,
     Location l,
     boolean isRealtime,
     ObaTripStatus status,
     ObaTripsForRouteResponse response) {
   boolean showInfo = m.isInfoWindowShown();
   m.setIcon(getVehicleIcon(isRealtime, status, response));
   // Update Hashmap with newest status - needed to show info when tapping on marker
   mVehicles.put(m, status);
   // Update vehicle position
   Location markerLoc = MapHelpV2.makeLocation(m.getPosition());
   // If its a small distance, animate the movement
   if (l.distanceTo(markerLoc) < MAX_VEHICLE_ANIMATION_DISTANCE) {
     AnimationUtil.animateMarkerTo(m, MapHelpV2.makeLatLng(l));
   } else {
     // Just snap the marker to the new location - large animations look weird
     m.setPosition(MapHelpV2.makeLatLng(l));
   }
   // If the info window was shown, make sure its open (changing the icon could have closed it)
   if (showInfo) {
     m.showInfoWindow();
   }
 }