CartoDB / mobile-ios-samples

iOS mobile app with CARTO Mobile SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to to get zoomed mapview

LakshmanaSwamy opened this issue · comments

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]
    }

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.

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