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 8454449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:02:14+00:00 2026-06-10T12:02:14+00:00

I am using google maps API and I have some code that tries to

  • 0

I am using google maps API and I have some code that tries to capture the position of the center of the map after the user has dragged it.

MapView mv = ...;

mv.setOnTouchListener(new OnTouchListener() {

    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            GeoPoint pt = mv.getMapCenter();
            //do something with the point
            return A;
        }
        return B;
    }
});

Now my problem is with the return values:

  • if B is false, the map gets dragged but I only see the ACTION_DOWN event and ACTION_UP is never triggered – which I understand
  • if B is true, I receive the ACTION_UP event, but the map is not dragged
  • it seems that whether A is true or false does not make a difference

What I want is to receive the ACTION_UP event AND to have the map dragged.

What am I missing here?

  • 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-10T12:02:16+00:00Added an answer on June 10, 2026 at 12:02 pm

    Here’s one solution: Instead of using the default MapView, use a custom MapView which has a GestureDetector, basically, this lets you create a custom event listener for your map which helps you avoid the issue of messing up the dragging etc. and moreover gives you are vast number of interaction options compared to the default MapView. A couple of months ago I’d faced a similar problem and so I decided to implement the solution I just mentioned. Here’s the code for the custom MapView called TapControlledMapView and the code for the interface for the custom listener is provided at the bottom : http://pastebin.com/kUrm9zFg.

    So to implement the listener, all you need to do is use the following code in your mapactivity class (Oh and in case you didn’t know this, you have to declare the following in your MapActivity layout XML file since you are using a custom MapView:

    <?xml version="1.0" encoding="utf-8"?>
    //The bottom line was the tricky business (You get ClassCastExceptions and whatnot)
    <NAMEOFYOURPROJECT.TapControlledMapView (ex: com.android.googlemapsapp.TapControlledMapView)
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="API_KEY_HERE"
    />
    

    and use the following code in your MapActivity class.

    mapView.setOnSingleTapListener(new OnSingleTapListener() {
    
    @Override
     public boolean onSingleTap(MotionEvent arg1) {
     if(arg1.getAction() == MotionEvent.ACTION_UP)
     {
      GeoPoint pt = mv.getMapCenter();
      // do something with the point.
      return ***true***;
     }
    return true;
    });
    

    Let me know how it goes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some JavaScript code that will read from the Google Maps API
I am using Google Maps API v3 , and have several map markers that
I have the following problem. I have embedded a map using Google Maps' API.
I have made my own map using the google maps api. It is a
I have some trobule using Google Maps API on Android. In onLocationChanged() I create
I'm showing some map tiles with google maps api v3 and jquery-ui-map (http://code.google.com/p/jquery-ui-map/) And
I have a map with multiple markers of companies using google maps API v3.
I have created an infobox using google maps api v3 and infoBox from the
I have a written up HTML file using the Google Maps API v3. All
I have an application using the Google Maps javscript API and the Infobox plug-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.