Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to to get zoomed mapview #18

Closed
LakshmanaSwamy opened this issue Apr 26, 2018 · 2 comments
Closed

how to to get zoomed mapview #18

LakshmanaSwamy opened this issue Apr 26, 2018 · 2 comments

Comments

@LakshmanaSwamy
Copy link

LakshmanaSwamy commented Apr 26, 2018

I have a method for calculating bounding box , for this method i am passing baseMap as an argument it always returns same coordinates even i zoomin /zoomout . Map coordinates remains same
Expected Result :- i want a map with respect to screen size when i zoom-in/ zoom-out

    func getBoundingBoxInMapPos(mapView:NTMapView)->[NTMapPos]{
        let topLeft :NTMapPos = mapView.screen(toMap: NTScreenPos.init(x: 0, y: 0))
        let topRight :NTMapPos = mapView.screen(toMap: NTScreenPos.init(x: Float(mapView.frame.width), y: 0))
        let bottomRight :NTMapPos = mapView.screen(toMap: NTScreenPos.init(x: Float(mapView.frame.height), y: Float(mapView.frame.width)))
        let bottomLeft :NTMapPos = mapView.screen(toMap: NTScreenPos.init(x: 0, y: Float(mapView.frame.height)))
        return [topLeft,topRight,bottomRight,bottomLeft,topLeft]
    }
@mtehver
Copy link
Contributor

mtehver commented Apr 30, 2018

This should work. Are you sure that mapView.frame.width and height are non-zero? During app initialization phase view dimensions may not have been set yet and that could explain the effect you are seeing.

@jaakla
Copy link
Contributor

jaakla commented May 8, 2018

Related SDK feature requests to make it safer: CartoDB/mobile-sdk#162

@jaakla jaakla closed this as completed May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants