Android Open Source - SmartNavi Extended Overlay Item






From Project

Back to project page SmartNavi.

License

The source code is released under:

Apache License

If you think the Android project SmartNavi listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.osmdroid.bonuspack.overlays;
/* w  w w  . ja  va  2  s . c  om*/
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.OverlayItem;
import android.graphics.Point;
import android.graphics.drawable.Drawable;

/**
 * An OverlayItem to use in ItemizedOverlayWithBubble<br>
 * - more complete: can contain an image and a sub-description that will be displayed in the bubble, <br>
 * - and flexible: attributes are modifiable<br>
 * 
 * Known Issues:<br>
 * - Bubble offset is not perfect on h&xhdpi resolutions, due to an osmdroid issue on marker drawing<br>
 * - Bubble offset is at 0 when using the default marker => set the marker on each item!<br>
 * 
 * @see ItemizedOverlayWithBubble
 * @author M.Kergall
 */
@Deprecated public class ExtendedOverlayItem extends OverlayItem {

  private String mTitle, mSnippet; // now, they are modifiable
  private String mSubDescription; //a third field that can be displayed in the infowindow, on a third line
  private Drawable mImage; //that will be shown in the infowindow. 
  //private GeoPoint mGeoPoint //unfortunately, this is not so simple...
  private Object mRelatedObject; //reference to an object (of any kind) linked to this item. 
  private float mAlpha;
  
  public ExtendedOverlayItem(String aTitle, String aDescription, GeoPoint aGeoPoint) {
    super(aTitle, aDescription, aGeoPoint);
    mTitle = aTitle;
    mSnippet = aDescription;
    mSubDescription = null;
    mImage = null;
    mRelatedObject = null;
    mAlpha = 1.0f; //default = opaque
  }

  public void setTitle(String title){
    mTitle = title;
  }
  
  public void setSnippet(String snippet){
    mSnippet = snippet;
  }
  
  public void setAlpha(float alpha){
    mAlpha = alpha;
    mMarker.setAlpha((int)(alpha*255));
  }

  /** set the marker icon */
  public void setIcon(Drawable icon){
    setMarker(icon);
  }
  
  public void setSubDescription(String aSubDescription){
    mSubDescription = aSubDescription;
  }
  
  /** set the image to be shown in the infowindow - this is not the marker icon. */
  public void setImage(Drawable anImage){
    mImage = anImage;
  }

  public void setRelatedObject(Object o){
    mRelatedObject = o;
  }
  
  public String getTitle() {
    return mTitle;
  }

  public String getDescription() {
    return mSnippet;
  }

  public String getSubDescription() {
    return mSubDescription;
  }

  public Drawable getIcon(){
    return mMarker;
  }
  
  public float getAlpha(){
    return mAlpha;
  }
  
  public Drawable getImage() {
    return mImage;
  }

  public Object getRelatedObject(){
    return mRelatedObject;
  }
  
  /** 
   * From a HotspotPlace and drawable dimensions (width, height), return the hotspot position. 
   * Could be a public method of HotspotPlace or OverlayItem... 
   */
  public Point getHotspot(HotspotPlace place, int w, int h){
    Point hp = new Point();
    if (place == null)
      place = HotspotPlace.BOTTOM_CENTER; //use same default than in osmdroid. 
    switch (place){
    case NONE : 
      hp.set(0, 0);
      break;
    case BOTTOM_CENTER:
      hp.set(w/2, 0);
      break;
    case LOWER_LEFT_CORNER: 
      hp.set(0, 0);
      break;
    case LOWER_RIGHT_CORNER:
      hp.set(w, 0);
      break;
    case CENTER:
      hp.set(w/2, -h/2);
      break;
    case LEFT_CENTER:
      hp.set(0, -h/2);
      break;
    case RIGHT_CENTER:
      hp.set(w, -h/2);
      break;
    case TOP_CENTER:
      hp.set(w/2, -h);
      break;
    case UPPER_LEFT_CORNER:
      hp.set(0, -h);
      break;
    case UPPER_RIGHT_CORNER:
      hp.set(w, -h);
      break;
    }
    return hp;
  }
  
  /**
   * Open the infowindow on the item. 
   * Centers the map view on the item if panIntoView is true. <br>
   */
  public void showBubble(InfoWindow bubble, MapView mapView, boolean panIntoView){
    //offset the bubble to be top-centered on the marker:
    Drawable marker = getMarker(0 /*OverlayItem.ITEM_STATE_FOCUSED_MASK*/);
    int markerWidth = 0, markerHeight = 0;
    if (marker != null){
      markerWidth = marker.getIntrinsicWidth(); 
      markerHeight = marker.getIntrinsicHeight();
    } //else... we don't have the default marker size => don't use default markers!!!
    Point markerH = getHotspot(getMarkerHotspot(), markerWidth, markerHeight);
    Point bubbleH = getHotspot(HotspotPlace.TOP_CENTER, markerWidth, markerHeight);
    bubbleH.offset(-markerH.x, -markerH.y);
    
    bubble.open(this, this.getPoint(), bubbleH.x, bubbleH.y);
    if (panIntoView)
      mapView.getController().animateTo(getPoint());
  }
}




Java Source Code List

com.ilm.sandwich.BuildConfig.java
com.ilm.sandwich.Config.java
com.ilm.sandwich.GoogleMapActivity.java
com.ilm.sandwich.Info.java
com.ilm.sandwich.MySupportMapFragment.java
com.ilm.sandwich.OsmMapActivity.java
com.ilm.sandwich.Settings.java
com.ilm.sandwich.Smartgeo.java
com.ilm.sandwich.StartChooser.java
com.ilm.sandwich.TouchableWrapper.java
com.ilm.sandwich.helferklassen.HttpRequests.java
com.ilm.sandwich.helferklassen.Locationer.java
com.ilm.sandwich.helferklassen.MapDownload.java
com.ilm.sandwich.helferklassen.MyItemizedOverlay.java
com.ilm.sandwich.helferklassen.PlacesAutoComplete.java
com.ilm.sandwich.helferklassen.PlacesTextSearch.java
com.ilm.sandwich.helferklassen.Rechnung.java
com.ilm.sandwich.helferklassen.SuggestionsAdapter.java
org.osmdroid.bonuspack.BuildConfig.java
org.osmdroid.bonuspack.BuildConfig.java
org.osmdroid.bonuspack.cachemanager.CacheManager.java
org.osmdroid.bonuspack.clustering.GridMarkerClusterer.java
org.osmdroid.bonuspack.clustering.MarkerClusterer.java
org.osmdroid.bonuspack.clustering.StaticCluster.java
org.osmdroid.bonuspack.kml.ColorStyle.java
org.osmdroid.bonuspack.kml.IconStyle.java
org.osmdroid.bonuspack.kml.KmlDocument.java
org.osmdroid.bonuspack.kml.KmlFeature.java
org.osmdroid.bonuspack.kml.KmlFolder.java
org.osmdroid.bonuspack.kml.KmlGeometry.java
org.osmdroid.bonuspack.kml.KmlGroundOverlay.java
org.osmdroid.bonuspack.kml.KmlLineString.java
org.osmdroid.bonuspack.kml.KmlMultiGeometry.java
org.osmdroid.bonuspack.kml.KmlPlacemark.java
org.osmdroid.bonuspack.kml.KmlPoint.java
org.osmdroid.bonuspack.kml.KmlPolygon.java
org.osmdroid.bonuspack.kml.LineStyle.java
org.osmdroid.bonuspack.kml.Style.java
org.osmdroid.bonuspack.location.FlickrPOIProvider.java
org.osmdroid.bonuspack.location.GeoNamesPOIProvider.java
org.osmdroid.bonuspack.location.GeocoderGisgraphy.java
org.osmdroid.bonuspack.location.GeocoderNominatimOld.java
org.osmdroid.bonuspack.location.GeocoderNominatim.java
org.osmdroid.bonuspack.location.NominatimPOIProvider.java
org.osmdroid.bonuspack.location.POI.java
org.osmdroid.bonuspack.location.PicasaPOIProvider.java
org.osmdroid.bonuspack.mapsforge.GenericMapView.java
org.osmdroid.bonuspack.mapsforge.MapsForgeTileModuleProvider.java
org.osmdroid.bonuspack.mapsforge.MapsForgeTileProvider.java
org.osmdroid.bonuspack.mapsforge.MapsForgeTileSource.java
org.osmdroid.bonuspack.overlays.DefaultInfoWindow.java
org.osmdroid.bonuspack.overlays.ExtendedOverlayItem.java
org.osmdroid.bonuspack.overlays.FolderOverlay.java
org.osmdroid.bonuspack.overlays.GroundOverlay.java
org.osmdroid.bonuspack.overlays.InfoWindow.java
org.osmdroid.bonuspack.overlays.ItemizedOverlayWithBubble.java
org.osmdroid.bonuspack.overlays.MapEventsOverlay.java
org.osmdroid.bonuspack.overlays.MapEventsReceiver.java
org.osmdroid.bonuspack.overlays.MarkerInfoWindow.java
org.osmdroid.bonuspack.overlays.Marker.java
org.osmdroid.bonuspack.overlays.Polygon.java
org.osmdroid.bonuspack.overlays.Polyline.java
org.osmdroid.bonuspack.routing.GoogleRoadManager.java
org.osmdroid.bonuspack.routing.MapQuestRoadManager.java
org.osmdroid.bonuspack.routing.OSRMRoadManager.java
org.osmdroid.bonuspack.routing.RoadLeg.java
org.osmdroid.bonuspack.routing.RoadManager.java
org.osmdroid.bonuspack.routing.RoadNode.java
org.osmdroid.bonuspack.routing.Road.java
org.osmdroid.bonuspack.utils.BonusPackHelper.java
org.osmdroid.bonuspack.utils.DouglasPeuckerReducer.java
org.osmdroid.bonuspack.utils.HttpConnection.java
org.osmdroid.bonuspack.utils.PolylineEncoder.java
org.osmdroid.bonuspack.utils.WebImageCache.java