Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8020761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:46:50+00:00 2026-06-04T21:46:50+00:00

I have created custom drawable marker which uses canvas to draw bounds. Everything works

  • 0

I have created custom drawable marker which uses canvas to draw
bounds. Everything works great excepts one thing: onItemSingleTapUp
not called when any marker on the screen taped.
Here is overlay creation code:

ItemizedIconOverlay<OverlayItem> groupsOverlay = new ItemizedIconOverlay<OverlayItem>(
    new ArrayList<OverlayItem>(),
    new OnItemGestureListener<OverlayItem>() {

        @Override
        public boolean onItemLongPress(int arg0, OverlayItem arg1) {                                
            return false;
        }

        @Override
        public boolean onItemSingleTapUp(int arg0, OverlayItem arg1) {

            if(arg1 == null){
                return false;
            }

            if(m_prevView != null){
                m_mapView.removeView(m_prevView);
                m_prevView = null;
            }

            View popUp = getLayoutInflater().inflate(R.layout.map_popup, m_mapView, false);
            TextView tv = (TextView)popUp.findViewById(R.id.popupTextView);
            tv.setText(arg1.getTitle());

            MapView.LayoutParams mapParams = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 
        ViewGroup.LayoutParams.WRAP_CONTENT,
        arg1.getPoint(),
        MapView.LayoutParams.BOTTOM_CENTER, 0, 0);
            m_mapView.addView(popUp, mapParams);
            m_prevView = popUp;

            return true;
        }
    }, new DefaultResourceProxyImpl(getApplicationContext()));

This is custom drawable marker:

package com.testapp.data; 
import android.graphics.Canvas; 
import android.graphics.ColorFilter; 
import android.graphics.Paint; 
import android.graphics.Paint.Align; 
import android.graphics.Paint.Style; 
import android.graphics.PixelFormat; 
import android.graphics.Rect; 
import android.graphics.RectF; 
import android.graphics.drawable.Drawable; 
public class GroupMarkerDrawable extends Drawable { 
        private final static int DELTA_BOX = 4; 
        private final Paint m_paint; 
        private String m_text; 
        private double m_pxRadius; 
        public GroupMarkerDrawable(double pxRadius, String text) { 
                m_text = text; 
                m_paint = new Paint(); 
                m_pxRadius = pxRadius; 
                m_paint.setAntiAlias(true); 
        } 
        @Override 
    public void draw(Canvas c) { 
                // Set the correct values in the Paint 
        m_paint.setARGB(190, 0, 0, 0); 
        m_paint.setStrokeWidth(2); 
        m_paint.setStyle(Style.STROKE); 
        m_paint.setTextAlign(Align.CENTER); 
        Rect bounds = new Rect(); 
        m_paint.getTextBounds(m_text, 0, m_text.length(), bounds); 
        int centerX = getBounds().centerX(); 
        int centerY = getBounds().centerY(); 
        int w2 = bounds.width() / 2; 
        int h2 = bounds.height() / 2; 
        Rect rect = new Rect(centerX - w2 - DELTA_BOX, centerY - h2 - 
DELTA_BOX, centerX + w2 + DELTA_BOX, centerY + h2 + DELTA_BOX); 
        // Draw it 
        c.drawCircle(centerX, centerY, (float) m_pxRadius, m_paint); 
        m_paint.setStyle(Style.FILL); 
        m_paint.setARGB(190, 0, 128, 0); 
        c.drawRect(rect, m_paint); 
        m_paint.setStyle(Style.STROKE); 
        m_paint.setARGB(190, 0, 0, 0); 
        c.drawRect(rect, m_paint); 
        c.drawText(m_text, centerX, centerY + h2, m_paint); 
    } 
        @Override 
        public int getOpacity() { 
                return PixelFormat.OPAQUE; 
        } 
        @Override 
        public void setAlpha(int arg0) { 
        } 
        @Override 
        public void setColorFilter(ColorFilter arg0) { 
        } 
} 

Same code using static drawable from resources, instead of
GroupMarkerDrawable, works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:46:52+00:00Added an answer on June 4, 2026 at 9:46 pm

    I found how to solve this. Just need to return proper dimensions for Drawable. This requires overriding of two methods in GroupMarkerDrawable. FOr example like this:

    @Override
    public int getIntrinsicHeight() {
        return m_pxRadius * 2;
    };
    
    @Override
    public int getIntrinsicWidth() {
        return m_pxRadius * 2;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom ExpandableListAdapter and everything works properly. What I'd like to
I have created custom posts and I want one page in my site to
I have created custom cell in which there are n number of image views.
I have created a custom tab layout which look like this,I want to make
I have created one gridview and use custom adapter for that. I added two
I have created one gridview and use custom adapter for that. I added two
I've created my own custom SurfaceView which works fine on its own but when
I want to create a custom drawable for RadioButton's button drawable. I have created
I have created a custom class from a tutorial online. It works fine, but
I have created custom jQuery UI widget called uiPopover, very similar to UI-dialog (in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.