Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>use this code , it's working fine for me :</p> <pre><code>public class CurrentLocationOverlay extends ItemizedOverlay&lt;OverlayItem&gt;{ private ArrayList&lt;OverlayItem&gt; mapOverlays = new ArrayList&lt;OverlayItem&gt;(); private MapView mapView; private Context context; //pin point drawable private Drawable marker; //balloon background private Drawable viewDrawable; private LinearLayout viewBubble; public CurrentLocationOverlay(Drawable defaultMarker) { super(boundCenterBottom(defaultMarker)); } /** * * @param defaultMarker * @param activity * @param context * @param mapView */ public CurrentLocationOverlay(Drawable defaultMarker , Context context, MapView mapView) { this(boundCenterBottom(defaultMarker)); this.mapView = mapView; this.context = context; marker = defaultMarker; growPopUpAnim = AnimationUtils.loadAnimation(context, R.anim.grow_from_bottom); viewDrawable = context.getResources().getDrawable(R.drawable.currlocpopup); } @Override protected OverlayItem createItem(int i) { return mapOverlays.get(i); } @Override public int size() { return mapOverlays.size(); } /** * * @param gp * @param title * @param msg */ public void addOverlay(GeoPoint gp , String title , String msg) { OverlayItem overlay = new OverlayItem(gp, title, msg); mapOverlays.add(overlay); this.populate(); } @Override protected boolean onTap(int index) { final int position = index; Log.v("Overlay index", "" + position); GeoPoint p = mapOverlays.get(index).getPoint(); addBubble(p , position); return true; } /** * * @param point * @param mapView */ private void addBubble(GeoPoint point , int index) { dimissbubble(mapView); // if there isn't any bubble on the screen enter if (viewBubble == null) { viewBubble = new LinearLayout(context); viewBubble.bringToFront(); viewBubble.setBackgroundDrawable(viewDrawable); TextView tv = new TextView(context); tv.setText(mapOverlays.get(index).getTitle()); tv.setTextSize(16); tv.setTextColor(Color.WHITE); tv.setTypeface(null, Typeface.BOLD); viewBubble.setGravity(Gravity.CENTER_HORIZONTAL); viewBubble.setPadding(10, 10, 10, 10); viewBubble.addView(tv); MapView.LayoutParams mvlp = new MapView.LayoutParams( MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT, point, 0, -marker.getIntrinsicHeight(), MapView.LayoutParams.BOTTOM_CENTER); mvlp.mode = MapView.LayoutParams.MODE_MAP; mapView.addView(viewBubble, mvlp); viewBubble.startAnimation(growPopUpAnim); // And the event. viewBubble.setOnClickListener(new OnClickListener() { // When we touch the bubble it is removed. And make null // viewBubble to reuse it. @Override public void onClick(View v) { mapView.removeView(viewBubble); viewBubble = null; } }); } } /** * * @param mapView */ private void dimissbubble(MapView mapView) { if (viewBubble != null) { mapView.removeView(viewBubble); viewBubble = null; } } } </code></pre> <p>add this :</p> <pre><code> GeoPoint p = new GeoPoint( (int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6)); CurrentLocationOverlay currentLocationOverlay = new CurrentLocationOverlay(mDrawable,context, mapView); currentLocationOverlay.addOverlay(p ,"Current Location" , ""); mapView.getOverlays().add(currentLocationOverlay); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload