Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to display an overlay item on Google Maps when a marker is tapped?
    text
    copied!<p>I already made a simple android application, which I also have integrated Google Maps in it.. It is also capable of connecting to MySQL (localhost) to display my desired places using longitude and latitude values.. My question is, is it possible to make another overlay item above Google Maps when a marker is clicked (just like what happens in foursquare)?</p> <p>To be specific, i want to display a text that contains the name of a place.</p> <p>Heres my class of displaying the overlay items. I made an onTap method, but it display a dialog box, I want to display a simple text box that shows the name of the place.</p> <pre><code> package finddroid.map; import java.util.ArrayList; import android.app.AlertDialog; import android.content.Context; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.text.TextPaint; import com.google.android.maps.GeoPoint; import com.google.android.maps.ItemizedOverlay; import com.google.android.maps.MapView; import com.google.android.maps.OverlayItem; public class CustomItemizedOverlay extends ItemizedOverlay&lt;OverlayItem&gt; { private int markerHeight; private ArrayList&lt;OverlayItem&gt; mapOverlays = new ArrayList&lt;OverlayItem&gt;(); private Context context; public CustomItemizedOverlay(Drawable defaultMarker) { super(boundCenterBottom(defaultMarker)); markerHeight = ((BitmapDrawable) defaultMarker).getBitmap().getHeight(); populate(); } public CustomItemizedOverlay(Drawable defaultMarker, Context context) { this(defaultMarker); this.context = context; } @Override protected OverlayItem createItem(int i) { return mapOverlays.get(i); } @Override public int size() { return mapOverlays.size(); } @Override //Event when a place is tapped protected boolean onTap(int index) { OverlayItem item = mapOverlays.get(index); AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.setTitle(item.getTitle()); dialog.setMessage(item.getSnippet()); dialog.show(); return true; } public void addOverlay(OverlayItem overlay) { mapOverlays.add(overlay); this.populate(); } } </code></pre>
 

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