title: custom overlay marker in osm
body: <p>I'm trying to make a custom marker for an OSMdroid map with a custom Overlay class. I think I get it but it gives me a StackOverflowError on the draw contructor</p>
  
  <p>Here's the code of the main activity</p>
  
  <pre><code>package com.example.osmap1;import java.util.List;
  
  import org.osmdroid.util.GeoPoint;
  import org.osmdroid.views.MapController;
  import org.osmdroid.views.MapView;
  import org.osmdroid.views.overlay.Overlay;
  
  import com.example.osmap1.herramientas.MiOverlay;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.Menu;
  
  public class MainActivity extends Activity {
  MapView map;
  MapController mc;
  GeoPoint gp;
  List&lt;Overlay&gt; mOverlays;
  
  private static MainActivity mainActivity=null;
  public static MainActivity getInstance(){
      if(mainActivity == null){
          mainActivity=new MainActivity();
  
      }
      return mainActivity;
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mainActivity=this;
      map=(MapView)findViewById(R.id.mapView);
  
      mc=map.getController();
      map.setBuiltInZoomControls(true);
      map.setMultiTouchControls(true);
  
      addPointToMapOverlay("43.528023","-5.672949");
  
  }
  
  private void addPointToMap (String latitud, String longitud){
  
      String coordenadas[]={latitud,longitud};
      double lat=Double.parseDouble(coordenadas[0]);
      double lng=Double.parseDouble(coordenadas[1]);
      GeoPoint gp=new GeoPoint((int)lat*1E6,(int)lng*1E6);
      mc.animateTo(gp);
      mc.setZoom(4);
      /*map.invalidate(); no funciona en osm*/
  }
  
  private void addPointToMapOverlay (String latitud, String longitud){
  
  
      String coordenadas[]={latitud,longitud};
      double lat=Double.parseDouble(coordenadas[0]);
      double lng=Double.parseDouble(coordenadas[1]);
      GeoPoint gp=new GeoPoint((int)lat*1E6,(int)lng*1E6);
  
      mOverlays=map.getOverlays();
      MiOverlay marker= new MiOverlay(gp);
      mOverlays.add(marker);
      mc.animateTo(gp);
      mc.setZoom(4);
      map.invalidate();
  }
  
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
   }
  }
  </code></pre>
  
  <p>And this is my custom class code</p>
  
  <pre><code>public class MiOverlay extends Overlay{
  
  private GeoPoint punto;
  
  
  public MiOverlay(GeoPoint point) {
  
      super(MainActivity.getInstance().getBaseContext());
      this.punto=point;
      // TODO Auto-generated constructor stub
  }
  
  @Override
  public void draw(Canvas canvas, MapView mapview, boolean shadow) {
  
      // TODO Auto-generated method stub
      this.draw(canvas, mapview, shadow);
  
      //se traduce el punto geo localizado a un punto en la pantalla
      Point scrnPoint = new Point();
      mapview.getProjection().toPixels(this.punto, scrnPoint);
  
      //se construye un bitmap a partir de la imagen
      Bitmap marker = BitmapFactory.decodeResource(MainActivity.getInstance().getResources(),com.example.osmap1.R.drawable.seas);
  
      //se dibuja la imagen del marker
      canvas.drawBitmap(marker, scrnPoint.x - marker.getWidth() / 2, scrnPoint.y - marker.getHeight() / 2, null);
  
  
  }
  
  public boolean onTouchEvent(MotionEvent event, MapView mapView) 
  {   
      //---when user lifts his finger---
      if (event.getAction() == 1) {                
          GeoPoint p = (GeoPoint) mapView.getProjection().fromPixels(
              (int) event.getX(),
              (int) event.getY());
              Toast.makeText(MainActivity.getInstance().getBaseContext(), 
                  p.getLatitudeE6() / 1E6 + "," + 
                  p.getLongitudeE6() /1E6 , 
                  Toast.LENGTH_SHORT).show();
      }                            
      return false;
  }        
  
  }
  </code></pre>
  
  <p>I think the problem coud be mapview.getProjection().toMapPixels(this.punto, scrnPoint) but I'm not sure... Any sugestion is wellcome</p>