Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Map MapOverlay Problem
    primarykey
    data
    text
    <p>My problem is I am displaying Google Map with PushPin on Particular Location but in my application if user can click on the pushpin the location name is display in toast or text-view, but i don't know how to do this?</p> <p>Please Help me.</p> <p>Following is my Code:-</p> <p>Map_Activity.java:-</p> <pre><code>public class Map_Activity extends MapActivity { String mArea; MapView mapView; MapController mc; GeoPoint p; String[] mLongitude,mLatitude,mAreaArray; double lat,lng; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.google_map_screen); Bundle bdl=getIntent().getExtras(); mArea= bdl.getString("Area Name"); mAreaArray=getResources().getStringArray(R.array.PlaceName); mLongitude=getResources().getStringArray(R.array.Longitude); mLatitude=getResources().getStringArray(R.array.Latitude); for(int i=0;i&lt;mAreaArray.length;i++){ if(mArea.equals(mAreaArray[i])){ lat=Float.valueOf(mLatitude[i]); lng=Float.valueOf(mLongitude[i]); } } mapView = (MapView) findViewById(R.id.googlemap); LinearLayout zoomLayout = (LinearLayout) findViewById(R.id.zoom); @SuppressWarnings("deprecation") View zoomView = mapView.getZoomControls(); zoomLayout.addView(zoomView, new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); mapView.displayZoomControls(true); mc = mapView.getController(); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); MapOverlay mapOverlay = new MapOverlay(); List&lt;Overlay&gt; listOfOverlays = mapView.getOverlays(); listOfOverlays.clear(); listOfOverlays.add(mapOverlay); mapView.invalidate(); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } public boolean onKeyDown(int keyCode, KeyEvent event) { MapController mc = mapView.getController(); switch (keyCode) { case KeyEvent.KEYCODE_3: mc.zoomIn(); break; case KeyEvent.KEYCODE_1: mc.zoomOut(); break; } return super.onKeyDown(keyCode, event); } class MapOverlay extends com.google.android.maps.Overlay { @Override public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { super.draw(canvas, mapView, shadow); // ---translate the GeoPoint to screen pixels--- Point screenPts = new Point(); mapView.getProjection().toPixels(p, screenPts); // ---add the marker--- Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pushpin); canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 50, null); return true; } @Override public boolean onTap(GeoPoint p, MapView mapView) { // TODO Auto-generated method stub Toast.makeText(Google_Map_Activity.this, "Sorry Don't Click", Toast.LENGTH_SHORT).show(); return super.onTap(p, mapView); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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