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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:34:09+00:00 2026-06-12T05:34:09+00:00

I have a MapView, and I call getController().zoomToSpan() on it. My problem with zoomToSpan()

  • 0

I have a MapView, and I call getController().zoomToSpan() on it. My problem with zoomToSpan() is that I want to have a consistent (for example, 15dp) padding outside of the map pins so that they may be selected without needing the user to pinch to zoom out. Currently I am populating zoomToSpan() with the minimum/maximum long/lat of the map pins, so the ones on the edges aren’t immediately visible or selectable.

I’ve considered using a fixed long/lat padding, but I have no guarantee that the map pins won’t be excessively close or far away from each other. So although a fixed long/lat padding may work for most cases, it won’t work for all cases.

This is how I am currently setting zoomToPan():

mapView.getController().zoomToSpan(MapPoint.convertToGeoPoint(Math.abs(fMinLat - fMaxLat)), MapPoint.convertToGeoPoint(Math.abs(fMinLong - fMaxLong)));

This is an idea I had on how to set it, but I am not sure if it actually solves the problem, or if there is a better way to do it:

mapView.getController().zoomToSpan(MapPoint.convertToGeoPoint((float) (Math.abs(fMinLat-fMaxLat) + (Math.abs(fMaxLat - fMaxLat)) * 0.5)), MapPoint.convertToGeoPoint((float) (Math.abs(fMinLong-fMaxLong) + (Math.abs(fMinLong - fMaxLong) * 0.5))));

I’ve already checked out these questions, but I’m past the point of making it work; I just want to make it polished: zoomToSpan implementation problem, and Calculating zoomToSpan() degrees based on min/max lat/lng to be in the mapView.

  • 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-12T05:34:11+00:00Added an answer on June 12, 2026 at 5:34 am

    Your solution should work fine. Just note that you have a typo in “(Math.abs(fMaxLat – fMaxLat)) * 0.5)”. You are using twice “fMaxLat”.

    You could write it in a simpler form:

    mapView.getController().zoomToSpan((int)(Math.abs(fMinLat-fMaxLat) * 1.5), (int)(Math.abs(fMinLong-fMaxLong) * 1.5));
    

    Then you can try different multiplying values between 1.0 and 1.99, to see what better achieve your expectations.

    Also keep in mind that zoom always change in steps (is not progressive) of powers of 2, meaning it will double the zoom or it will reduce to half. The final result achieved will vary with different points in the map, which can fit closely to a zoom value and very distante from the edge on previous one.

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

Sidebar

Related Questions

I have an application that uses the mapview-overlay-manager code to draw map markers on
I have a MapView that will contain alot of overlays. For this i've extended
I have a simple mapview that has the following viewdidload method and didupdate to
In my map application the MapView controller is opens well in phone call mode.
I have a mapView with a detail disclosure indicator that when touched needs to
i have a mapview that shows some pois with a ItemizedOverlay. When i tap
I have activity with MapView, TextView, 3 ImageButton and 1 simple Button. First call
I'm developing on an app that is location-based, I have a mapView set to
Here's the deal: I have an Android application that needs to call a web
I have a view controller with an MKMapView that calls [self.mapView setRegion:region animated:YES]; which

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.