Creating Custom Overlay on the map?

Okay, I tried to do things on my Own, and put this code to get the above effect.

Okay, I tried to do things on my Own, and put this code to get the above effect: public class MarkerOverlay extends Overlay { Geocoder geoCoder = null; public MarkerOverlay() { super(); } @Override public boolean onTap(GeoPoint geoPoint, MapView mapView){ selectedLatitude = geoPoint. GetLatitudeE6(); selectedLongitude = geoPoint. GetLongitudeE6(); return super.

OnTap(geoPoint,mapView); } @Override public void draw(Canvas canvas, MapView mapV, boolean shadow){ if(shadow){ Projection projection = mapV.getProjection(); Point pt = new Point(); projection. ToPixels(globalGeoPoint,pt); GeoPoint newGeos = new GeoPoint(selectedLat+(100),selectedLong); // adjust your radius accordingly Point pt2 = new Point(); projection. ToPixels(newGeos,pt2); float circleRadius = Math.

Abs(pt2. Y-pt. Y); Paint circlePaint = new Paint(Paint.

ANTI_ALIAS_FLAG); circlePaint. SetColor(0x30000000); circlePaint. SetStyle(Style.

FILL_AND_STROKE); canvas. DrawCircle((float)pt. X, (float)pt.

Y, circleRadius, circlePaint); circlePaint. SetColor(0x99000000); circlePaint. SetStyle(Style.

STROKE); canvas. DrawCircle((float)pt. X, (float)pt.

Y, circleRadius, circlePaint); Bitmap markerBitmap = BitmapFactory. DecodeResource(getApplicationContext().getResources(),R.drawable. Pin); canvas.

DrawBitmap(markerBitmap,pt. X,pt. Y-markerBitmap.getHeight(),null); super.

Draw(canvas,mapV,shadow); } } } This let me have following effect: The calculation used may not be what you want. Its just for demonstration purposes. Real range/distance calculation requires the use of bearing too and has some specific formula.

Let me know if you have any questions regarding this.

Please guide I want to implement same thing. – UMAR Apr 16 '11 at 12:04 and please paste code of its usage from google map. How you call this class any help would be appreciated.

– UMAR Apr 16 '11 at 12:16 Sorry, it is the latitude/longitude the user tapped on. Its a global variable which holds these values. This class is an Inner class of my MapActivity – Sheikh Aman Apr 17 '11 at 8:06 how you call it from google map?

To create this current overlay item can you please add that code also so that I can utilize it? – UMAR May 1 '11 at 11:49 1 While you add the overlay, use this class. And the onDraw() method will always be called whenever Android draws map tiles (on zoom, pan etc) – Sheikh Aman May 1 '11 at 17:18.

Extend the class ItemizedOverlay to override the draw() method. The Canvas where overlays are drawn is passed to that method and you can call drawCircle or anything that's needed to make your range dragger appear.

This is a good option, but as it can be seen in the image above, I'll need to have the points where a marker currently is. First it will give me geoPoints, and I'll have to convert them into screen-pixel format (co-ordinates like x,y) I can't anything for that! :-/ – Sheikh Aman Dec 15 '10 at 13:26 Check this out: code.google.com/android/add-ons/google-a...… – ognian Dec 15 '10 at 14:52 Cool.. I got the mouse points.

However, Since I am also using the onTap method to put a marker at the position where user clicks, after overriding the draw() method, onTap mechanism isn't working. Because it used to call the default draw() method for putting up markers, which I have overridden now. Any solution to this!?

– Sheikh Aman Dec 17 '10 at 6:11.

I have already implemented a MapView Labeeb, and it is working quite fine. But have to get the aforesaid effect. – Sheikh Aman Dec 14 '10 at 5:37.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions