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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:14:24+00:00 2026-06-13T04:14:24+00:00

Summary I need to be able to move from my current mapview to a

  • 0

Summary

I need to be able to move from my current mapview to a latitude/longitude span. I want this move to happen in an animated sort of way (similar to how animateTo works). I need to go from my current view, and zoom in or out to end up at the target latitude/longitude span. Below is the code I’m using to do this when I use zoomLevels. But I have to use spans, not zoom levels to accomplish this.

[Edit]

Here’s what I’m doing for animateTo. I need the equivalent of this, but using Lat/Lng Span to end up at my final view (i need to be zoomed and centered, showing the lat/lng span provided). As you’ll notice, i’m using targetZoomLevel and currentZoomLevel to determine how much zooming to do… I need to be using the lat/lng span instead.

public static void smoothZoom(final MapController controller,
        final int currentZoomLevel, final int targetZoomLevel,
        int latitude, int longitude) {

    final Handler handler = new Handler();

    controller.animateTo(new GeoPoint(latitude, longitude), new Runnable() {
        public void run() {

            int currentZoom = currentZoomLevel;
            int zoomTarget = targetZoomLevel;

            // Smooth zoom handler
            // int zoomLevel = _mapView.getZoomLevel();
            // int targetZoomLevel = targetLevel;
            long delay = 0;

            if (zoomTarget > currentZoom) {
                while (currentZoom++ < zoomTarget) {
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            controller.zoomIn();
                        }
                    }, delay);

                    delay += 150; // Change this to whatever is good on the
                                    // device
                }
            } 
        }
    });
}

[Edit]

I really need this code for my application now, there is no way around it. First person to help me get working code gets 250 rep.

  • 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-13T04:14:25+00:00Added an answer on June 13, 2026 at 4:14 am

    Is this the kind of solution you’re looking for?

    public static void zoomSpan(final MapView mapView, int northernLat, int southernLat, int easternLon, int westernLon) {
        final int latSpan = northernLat - southernLat;
        final int lonSpan = easternLon - westernLon;
        latCenter = southernLat + latSpan / 2;
        lonCenter = westernLon + lonSpan / 2;
    
        final MapController controller = mapView.getController();
        final Handler handler = new Handler();
    
        final Runnable zoomRunnable = new Runnable() {
            public void run() {
                int viewLatSpan = mapView.getLatitudeSpan();
                int viewLonSpan = mapView.getLongitudeSpan();
                boolean actionTaken = false;
                if (mapView.getZoomLevel() > 1 && (latSpan > viewLatSpan || lonSpan > viewLonSpan)) {
                    controller.zoomOut();
                    actionTaken = true;
                }
                if (mapView.getZoomLevel() < mapView.getMaxZoomLevel() && latSpan * 2 <= viewLatSpan && lonSpan * 2 <= viewLonSpan) {
                    controller.zoomIn();
                    actionTaken = true;
                }
                if (actionTaken)
                    handler.post(zoomRunnable);
            }
        };
    
        controller.animateTo(latCenter, lonCenter, zoomRunnable);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Summary: My users need to be able to edit the structure of their dynamically
Summary: 1. Need to open a new window to display a survey from a
Summary: I want to know if it is possible to do something like this:
Summary: I want to be able to run a query against an external database
Executive summary: I need a way to determine whether a Windows process I've spawned
Summary: I want a horizontal row of ImageButtons to scale down evenly to fit
Summary: I want to display a value (in a text box) stored in another
Summary : is there a way to get the unique lines from a file
I need to build some sort of a custom CMS for a client of
I need to be able to flush a single entity to the DB during

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.