Reputation: 406
I have tried to covert the marker position latitude-longitude to iPhone screen x and y coordinate, but it gives me negative value sometimes.
MapView is added in main view from storyboard. self.mapView.frame - It is equal to main view frame iPhone 8 plus simulator = (origin = (x = 0, y = 0), size = (width = 414, height = 736))
Marker position : (latitude = 22.811061859130859, longitude = 70.862533569335938)
CGPoint pointInScreen = [self.mapView.projection pointForCoordinate:marker.position];
Returns value - (x = -38547.58203125, y = 7061.60107421875) Which is not screen point. My marker is visible on the screen.
Can anyone suggest me the right way to find out the screen x,y coordinate based on the marker latitude-longitude position?
Upvotes: 0
Views: 1085
Reputation: 13354
There are few things to check:
marker
should be visible on map.coordinates
.[self.mapView.projection pointForCoordinate:marker.position]
function will work after loading the map properly.Upvotes: 1
Reputation: 9503
You have to do like this
Upvotes: 0