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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:56:28+00:00 2026-05-26T20:56:28+00:00

I am using the fromPixels() function in osmdroid (3.05) like so: public boolean onScroll(ScrollEvent

  • 0

I am using the fromPixels() function in osmdroid (3.05) like so:

public boolean onScroll(ScrollEvent e) {

    //get the scroll's destination
    GeoPoint g = (GeoPoint) e.getSource().getProjection().fromPixels(e.getX(), e.getY());
    Toast.makeText(e.getSource().getContext(), "in e6: " +
    g.getLongitudeE6() + " " + g.getLatitudeE6() + " in deg's" + 
    convertToDecimalDegrees(g.getLongitudeE6())
    + " " + convertToDecimalDegrees(g.getLatitudeE6()), Toast.LENGTH_LONG).show();}  

I am scrolling the map somewhere near -0.0029109 51.9933734 but in the toast i get:
-0.9613029999999999 76.60554499999999 so it seems like the lat is way off (the convert to decimal
degrees is Ok – i just multiply by 1E-6)
Am i using the function incorrectly?
From what i read it seems like my usage is fine, also i read that there used to be a problem with
that function but that it should be fixed now

Thanks in advance!
Omri

  • 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-05-26T20:56:29+00:00Added an answer on May 26, 2026 at 8:56 pm

    I know this thread is a little old but the answer to this question can be found on http://code.google.com/p/osmdroid/issues/detail?id=209
    To point is to set max extent of map and restrict scrolling to that extent.
    Below is the summary of issue mentioned above (Add the code below to MapView.java)

    protected Rect mScrollableAreaLimit = null;
    
    public void setScrollableAreaLimit(BoundingBoxE6 boundingBox) {  
        final int worldSize_2 =  TileSystem.MapSize(MapViewConstants.MAXIMUM_ZOOMLEVEL) / 2;
        // Clear scrollable area limit if null passed.
        if (boundingBox == null) {
            mScrollableAreaLimit = null;
            return;
        }
    
        // Get NW/upper-left
        final Point upperLeft = TileSystem.LatLongToPixelXY(boundingBox.getLatNorthE6() / 1E6,
                boundingBox.getLonWestE6() / 1E6, MapViewConstants.MAXIMUM_ZOOMLEVEL, null);
        upperLeft.offset(-worldSize_2, -worldSize_2);
    
        // Get SE/lower-right
        final Point lowerRight = TileSystem.LatLongToPixelXY(boundingBox.getLatSouthE6() / 1E6,
                boundingBox.getLonEastE6() / 1E6, MapViewConstants.MAXIMUM_ZOOMLEVEL, null);
        lowerRight.offset(-worldSize_2, -worldSize_2);
        mScrollableAreaLimit = new Rect(upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y);
    }
    

    Now you can call the setScrollableAreaLimit method when map view is created or you can expand constructor with BoundingBoxE6 parameter.

    Hope this helps.

    In addition to this a correction for double tap bug is needed http://code.google.com/p/osmdroid/issues/detail?id=209#c23

    @Override
    public void computeScroll() {
        if (mScroller.computeScrollOffset()) {
            if (mScroller.isFinished()) {
                // This will facilitate snapping-to any Snappable points.
                setZoomLevel(mZoomLevel);
            } else {
                /* correction for double tap */
                int targetZoomLevel = getZoomLevel();
                if (targetZoomLevel == mZoomLevel)
                    scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
            }
            postInvalidate(); // Keep on drawing until the animation has
            // finished.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I just cant get this working. I tried using the code below with onTouchEventand
Using Rails 3.2.0 with haml and sass: I Would like to link an external
Using the HTML5 File API I can get the Binary String representation of a
Using Delphi 2010. I am looking for (possibly) a function or procedure which can
using file_get_contents , I open an Internet URL and get the contents of this
Using the current request I can get the URL hostname with: HttpContext.Current.Request.Url.Host But -
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
Using Java Reflection, is it possible to get the name of a local variable?
Using online interfaces to a version control system is a nice way to have

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.