Reputation: 1237
I am trying to use the following function zoomWithLatitudeLongitudeBoundsSouthWest
to zoom to the extent of the uk. I have the following latlongs:
SouthWest = (latitude = 49.724355000000003, longitude = -8.7919210000000003)
NorthEast = (latitude = 59.556961999999999, longitude = 2.102922)
So use the following:
[rmMapView zoomWithLatitudeLongitudeBoundsSouthWest:self.southWest northEast:self.northEast animated:YES];
When this is passed in to the function it returns the following projected bounds:
origin: (185130.482481, 6398696.510918) size: (48919.698096, 66653.088655)
However, this is not the extent of the UK as expected, it actually zooms in to France. During the process I also set the constraints of the map using the following:
[rmMapView setConstraintsSouthWest:self.southWest northEast:self.northEast];
When I pan around the map and zoom out, the constraints of the map are correct i.e. I can't move outside of the UK. This means that the southWest and northEast are set correctly, however, the zoomWithLatitudeLongitude function is not moving to the correct area. I use this function on smaller areas (subsections of the uk) and it seems to work correctly. Can anyone tell me if they have had similar issues or what I am doing wrong?
Thanks
Upvotes: 1
Views: 720
Reputation: 1032
For some reason there is a problem with the MapView frame during initialisation. Updating the frame based on another view in the ViewDidLoad seemed to fix the problem.
[self.mapView setFrame:self.view.frame];
Not investigated this fully but seemed to be a good workaround.
Upvotes: 0
Reputation: 31
Maybe this is little late, but this issue lost me a whole day of work. You are probably testing on 64 bit devices. Try your code on 32 bit devices and it should probably be working fine.
Mapbox had a problem of centering the zoom on 64 bit devices (the zoom level is ok, but the map offset is not).
I worked around this solution by setting the new center of the map after setting the zoom. Try adding this line:
[rmMapView setCenterCoordinate:CLLocationCoordinate2DMake(lat,lng)];
just after zoomWithLatitudeLongitudeBoundsSouthWest
where lat = (latMin + latMax)/2 and lng = (lngMin + lngMax)/2)
NOTE: I was passing animated:NO so this worked in my case. Try somehow animating seCenterCoordinate in your case.
Upvotes: 3