iosxcodedictionaryroute-me

Zooming out with RMMapView constrained to coordinates


I'm trying to setup an offline map in an iPhone app, but the result is not very good.

I'm using the route-me framework, I've got an offline file .db (created by tiles2sqlite) and the map view is constrained with coordinates (using setConstraintsSW:NE:).

My problem is appearing when zooming out (pinch gesture), this error message "Zooming will move map out of bounds: no zoom" is always present and it's very difficult to zoom out when you are not near the real center of the map.

Is there a solution to have the same result as in Offmaps (iOS app) where the map has a nice scrollview behavior?

Cheers.

Cyril


Solution

  • I had to edit RMMapView.m source code to make a quick fix. Find - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center animated:(BOOL)animated method (near line 300). It has constrain logic, I turned it off:

    - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center animated:(BOOL)animated   
    {
        if ( _constrainMovement && false ) // turn constraint checks off 
        {
            //check that bounds after zoom don't exceed map constraints
            //the logic is copued from the method zoomByFactor,
            float _zoomFactor = [self.contents adjustZoomForBoundingMask:zoomFactor];
            float zoomDelta = log2f(_zoomFactor);
            ...
        }
        ...
    }
    

    Now map is zoomed smoothly, but this fix could have side effects.