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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:45:28+00:00 2026-06-18T01:45:28+00:00

Can I limit the Google Maps V2 (Android) at 180° / -180° longitude (like

  • 0

Can I limit the Google Maps V2 (Android) at 180° / -180° longitude (like iOS MapKit)? I don’t want it to wrap around, as I’m trying to implement a clusterin algorithm, and the 180 / -180 degree split would make it difficult.

I would like the panning to be limited at the red line:

enter image description 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-18T01:45:29+00:00Added an answer on June 18, 2026 at 1:45 am

    So I created a solution that should be fine. If the user panns the map across the -180 / 180 border, the map will flip to the other side. So wrapping the map is still possible, but the “dangerous” area is never displayed.

    I had to create a custom MapView:

    public class CustomMapView extends MapView {
    
        private double prevLongitude;
    
        @Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
            boolean retVal = correctCamera();
            prevLongitude = getMap().getCameraPosition().target.longitude;
            return retVal;
        }
    
        public boolean correctCamera() {    
            if (getMap().getProjection().getVisibleRegion().latLngBounds.northeast.longitude < getMap().getProjection().getVisibleRegion().latLngBounds.southwest.longitude) {
                double diff = getMap().getProjection().getVisibleRegion().latLngBounds.southwest.longitude - getMap().getProjection().getVisibleRegion().latLngBounds.northeast.longitude;
                double longitudeSW;
                double longitudeNE;
    
                double longitudeDiff = (360-diff) / 25; 
    
                // use > 0 if you want the map to jump to the other side
                // <= 0 will cause the map to flip back
                if (prevLongitude > 0) {
                    longitudeSW = -180 + longitudeDiff;
                    longitudeNE = -180 + longitudeDiff - diff;
                } else {
                    longitudeSW = 180 - longitudeDiff + diff;
                    longitudeNE = 180 - longitudeDiff;
                }
                LatLngBounds bounds = new LatLngBounds(
                                            new LatLng(getMap().getCameraPosition().target.latitude, longitudeSW), 
                                            new LatLng(getMap().getCameraPosition().target.latitude, longitudeNE)
                                      );
                getMap().animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
    
                return true;
            }
    
            return false;
        }
    }
    

    And the xml:

    <com.ieffects.clustermap.CustomMapView
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    

    And for the GoogleMap (mapView.getMap()):

    map.setOnCameraChangeListener(new OnCameraChangeListener() {
        @Override
        public void onCameraChange(CameraPosition position) {
            mapView.correctCamera();
        }
    });
    

    This is needed if the user let’s the map “fly” into the dangerous region.

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

Sidebar

Related Questions

I'd like to create a plug-in architecture where I can limit an assemblies API
How can i limit a foreach() statement? Say i only want it to run
I'm trying to get a static image of a hiking trail from google maps
Google maps and geocoding functions have a request limit. With Google Maps the limit
Although I like the accuracy of google maps, I was wondering how easy it
GOOGLE MAPS API V3 is what i'm trying to use. I have all the
I'm using JavaScript Places Library http://code.google.com/intl/en/apis/maps/documentation/javascript/places.html However, I can't find how to set the
According to Google Map's Geocode API documentation: https://developers.google.com/maps/documentation/geocoding/index#GeocodingRequests you can simply make a call
I need to limit what Dates a user can pick from the com.google.gwt.user.datepicker.client.DateBox .
I want to create a store locator with Google Maps. I have a database

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.