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

  • SEARCH
  • Home
  • 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 9199797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:37:04+00:00 2026-06-17T22:37:04+00:00

I can’t find an example on how to intercept the map touch on the

  • 0

I can’t find an example on how to intercept the map touch on the new Google Maps API v2.

I need to know when the user touches the map in order to stop a thread (the centering of the map around my current location).

  • 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-17T22:37:06+00:00Added an answer on June 17, 2026 at 10:37 pm

    @ape wrote an answer here on how to intercept the map clicks, but I need to intercept the touches, and then he suggested the following link in a comment of its answer, How to handle onTouch event for map in Google Map API v2?.

    That solution seems to be a possible workaround, but the suggested code was incomplete. For this reason I rewrote and tested it, and now it works.

    Here it is the working code:

    I created the class MySupportMapFragment.java

    import com.google.android.gms.maps.SupportMapFragment;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    
    public class MySupportMapFragment extends SupportMapFragment {
        public View mOriginalContentView;
        public TouchableWrapper mTouchView;
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
            mOriginalContentView = super.onCreateView(inflater, parent, savedInstanceState);
            mTouchView = new TouchableWrapper(getActivity());
            mTouchView.addView(mOriginalContentView);
            return mTouchView;
        }
    
        @Override
        public View getView() {
            return mOriginalContentView;
        }
    }
    

    I even created the class TouchableWrapper.java:

    import android.content.Context;
    import android.view.MotionEvent;
    import android.widget.FrameLayout;
    
    public class TouchableWrapper extends FrameLayout {
    
        public TouchableWrapper(Context context) {
            super(context);
        }
    
        @Override
        public boolean dispatchTouchEvent(MotionEvent event) {
    
            switch (event.getAction()) {
    
                case MotionEvent.ACTION_DOWN:
                      MainActivity.mMapIsTouched = true;
                      break;
    
                case MotionEvent.ACTION_UP:
                      MainActivity.mMapIsTouched = false;
                      break;
            }
            return super.dispatchTouchEvent(event);
        }
    }
    

    In the layout I declare it this way:

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/mapFragment"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_below="@+id/buttonBar"
              class="com.myFactory.myApp.MySupportMapFragment"
    />
    

    Just for test in the main Activity I wrote only the following:

    public class MainActivity extends FragmentActivity {
        public static boolean mMapIsTouched = false;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
Can anyone let me know how can we change the value of kendo combobox
Can I authenticate with just Google account username and password instead of using OAuth?
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can someone please help me find the memory leak which is occurring here? I
Can MOSS integrate and get user profiles from multiple Active Directory and/or LDAP stores?
Does anyone know how can I replace this 2 symbol below from the string
Can someone explain dependency injection with a basic .NET example and provide a few
Can not find scala.actors package in latest milestones, while it still presents in scaladocs:
Can anyone provide an example of how to retrieve captions for YouTube video? Based

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.