Remove shadow from overlay marker

Tutorials that use the MapActivity. Many using GPS functionality.

Remove shadow from overlay marker

Postby mistajase » Fri May 07, 2010 6:50 am

I've almost got my app finished but I've noticed a shadow around some of my larger markers,
my overlay item looks like this :-

Code: Select all
if (festieid ==6){
    List<Overlay> mapOverlays = mapView.getOverlays();
   // Drawable drawable = this.getResources().getDrawable(R.drawable.glastomap);
   
    this.readingmap = getResources().getDrawable(R.drawable.readingmap);
        this.readingmap.setBounds(0, 75, this.readingmap.getIntrinsicWidth(), this.readingmap
            .getIntrinsicHeight());


       String coordinates[] = {"51.465906", "-0.998769"};
           double lat = Double.parseDouble(coordinates[0]);
           double lng = Double.parseDouble(coordinates[1]);
   
           p = new GeoPoint(
               (int) (lat * 1E6),
               (int) (lng * 1E6));
     
       
       
    SiteItemizedOverlay itemizedoverlay = new SiteItemizedOverlay(readingmap);

    //GeoPoint point = new GeoPoint(51465906,  0.0);
    OverlayItem overlayitem = new OverlayItem(p, "Reading", "Reading Carling");
   
    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);
   
   
        mapController.animateTo(p);

};


This works fine but the shadow really annoys me (I never wanted the shadow, it put it on automatically!).
Is there any way of turning it off?

cheers guyz!
mistajase
Junior Developer
Junior Developer
 
Posts: 20
Joined: Thu Nov 26, 2009 4:28 am

Top

Re: Remove shadow from overlay marker

Postby loudo » Tue May 18, 2010 3:26 pm

Hello,

Try to create a subclass with ItemizedOverlay

http://code.google.com/intl/fr/android/ ... erlay.html

For the draw method do this :

public void draw(android.graphics.Canvas canvas,
MapView mapView,
boolean shadow) {

super.draw(canvas, mapView, false);

}
loudo
Freshman
Freshman
 
Posts: 5
Joined: Thu Jul 23, 2009 1:39 pm

Re: Remove shadow from overlay marker

Postby pedroteixeira07 » Tue Jun 08, 2010 4:37 pm

Cool, this worked perfectly!

I created this class public class mapOverlays extends ItemizedOverlay but I get this notice that it should be parameterized. Do you know something about it?
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Re: Remove shadow from overlay marker

Postby loudo » Wed Jun 09, 2010 9:15 am

What notice ?
loudo
Freshman
Freshman
 
Posts: 5
Joined: Thu Jul 23, 2009 1:39 pm

Re: Remove shadow from overlay marker

Postby pedroteixeira07 » Wed Jun 09, 2010 10:41 am

This one:
Code: Select all
ItemizedOverlay is a raw type. References to generic type ItemizedOverlay<Item> should be parameterized
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Re: Remove shadow from overlay marker

Postby loudo » Wed Jun 09, 2010 10:54 am

I will check in my code and i will reply to you.
loudo
Freshman
Freshman
 
Posts: 5
Joined: Thu Jul 23, 2009 1:39 pm

Top

Re: Remove shadow from overlay marker

Postby shipbrother » Thu Jun 10, 2010 7:12 am

class MyMapOverlay extends ItemizedOverlay<MyMapItem> {
...
}
This is what it means.
And you will need to create MyMapItem and use only its instances in overlay.
shipbrother
Freshman
Freshman
 
Posts: 9
Joined: Fri May 28, 2010 5:27 pm

Re: Remove shadow from overlay marker

Postby pedroteixeira07 » Sun Jun 13, 2010 9:14 pm

Do you have an example of a ''MyMapItem'' to see how that goes? Thank you
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Re: Remove shadow from overlay marker

Postby shipbrother » Mon Jun 14, 2010 7:35 am

public class MyMapItem extends OverlayItem {
public MyMapItem(GeoPoint point, String title, String snippet) {
super(point, title, snippet);
}
}
In this simple case this class plays a role of "categorizer". Generally you can put any business logic here, override methods of OverlayItem and make some special handling of your overlay items of this specific type. (if your app requires this)
shipbrother
Freshman
Freshman
 
Posts: 9
Joined: Fri May 28, 2010 5:27 pm

Re: Remove shadow from overlay marker

Postby smcbride15 » Thu Sep 16, 2010 3:13 pm

Hmm, I still can't get the shadow removed. I'm subclassing ItemizedOverlay as per the example and calling onDraw as follows:

public boolean OnDraw(Canvas canvas,MapView mapView, boolean shadow){

super.draw(canvas, mapView, false);
return true;
}

Any ideas?
smcbride15
Freshman
Freshman
 
Posts: 2
Joined: Wed Jul 22, 2009 10:19 pm

Re: Remove shadow from overlay marker

Postby Knish » Mon Nov 22, 2010 1:17 pm

I don't see the class ItemizedOverlay having a method called OnDraw. Try to override draw instead as in the following snippet. This worked for me.

@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow){
super.draw(canvas, mapView, false);
}
Knish
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Nov 22, 2010 1:07 pm

Re: Remove shadow from overlay marker

Postby droidmonkey » Wed Jan 05, 2011 1:25 pm

Sorry for a slight bump, but using the above code is actually wrong. This will result in the same overlay being drawn TWICE. This is because draw is called once to draw the shadow and then again to draw the regular overlay. The correct code should be:

@Override
public void draw( Canvas c, MapView m, boolean shadow ) {
if ( shadow )
return;

super.draw( c, m, shadow );
}
droidmonkey
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Jan 05, 2011 1:23 pm

Re: Remove shadow from overlay marker

Postby assaka » Thu Mar 10, 2011 1:01 pm

You can simply add this to your ItemizedOverlay class:

@Override
public void draw( Canvas c, MapView m, boolean shadow ) {
super.draw( c, m, false );
}
assaka
Freshman
Freshman
 
Posts: 4
Joined: Tue Jan 25, 2011 12:20 am

Re: Remove shadow from overlay marker

Postby aakash » Fri Oct 21, 2011 7:38 am

I was looking for this one & its work like a charm.
Thank you so much. :D :D
Let me develop something.

Grrrrrrrrrrr
aakash
Developer
Developer
 
Posts: 29
Joined: Thu Aug 11, 2011 7:10 am

Re: Remove shadow from overlay marker

Postby parson » Wed Nov 02, 2011 8:31 am

For technical reasons, I wish to remove shadow behind markers. I found a lot of time this question in the group, without "true answer". Thank you for you suggestions, cell phone spywareis much of help!
Last edited by parson on Wed Jun 20, 2012 1:09 pm, edited 1 time in total.
parson
Freshman
Freshman
 
Posts: 3
Joined: Wed Nov 02, 2011 8:28 am

Top
Next

Return to Map Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests