Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle maps marker error
    text
    copied!<p>I am trying to put the marker on the map and i have done it but the problem is that it is showing all the markers.previous &amp; recent also.I dont want to show the previous markers instead i just want to show the marker on the place which is clicked recently.All other markers should not be seen</p> <p>I have written the code with the help of follwing tutorial</p> <p><a href="http://mobiforge.com/developing/story/using-google-maps-android" rel="nofollow">http://mobiforge.com/developing/story/using-google-maps-android</a></p> <p>And my Code is</p> <pre><code>public class SelectLocation extends MapActivity { MapView mapView; MapController mc; GeoPoint p; String coordinates[]; class MapOverlay extends com.google.android.maps.Overlay { private GeoPoint p; public MapOverlay(GeoPoint p){ this.p = p; } @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; } public boolean onTouchEvent(MotionEvent event, MapView mapView) { //---when user lifts his finger--- if (event.getAction() == 1) { GeoPoint p = mapView.getProjection().fromPixels( (int) event.getX(), (int) event.getY()); Toast.makeText(getBaseContext(), p.getLatitudeE6() / 1E6 + "," + p.getLongitudeE6() /1E6 , Toast.LENGTH_SHORT).show(); mapView.getOverlays().add(new MapOverlay(p)); Intent i=new Intent(SelectLocation.this,SetLocat.class); startActivity(i); } return false; } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.selectlocation); mapView = (MapView) findViewById(R.id.mapView); mapView.setBuiltInZoomControls(true); mc = mapView.getController(); String coordinates[] = {"1.352566007", "103.78921587"}; double lat = Double.parseDouble(coordinates[0]); double lng = Double.parseDouble(coordinates[1]); p = new GeoPoint( (int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); MapOverlay mapOverlay = new MapOverlay(p); List&lt;Overlay&gt; listOfOverlays = mapView.getOverlays(); listOfOverlays.clear(); listOfOverlays.add(mapOverlay); } /*protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; }*/ @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } </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