How to zoom to current location on map with Skobbler - ios

I want to zoom to current user's location upon initialising SKMap.
Right now I don't know if it's even possible (even though it's impossible that it's impossible) but I fail to find the way through documentation.
Only thing I found is method for android
mapView.setZoom(int);
But there is nothing like it for iOS.
How can I zoom to the users current location then?

Simply create a region for your map to focus onto:
SKCoordinateRegion region;
region.center = CLLocationCoordinate2DMake(52.5233, 13.4127);
region.zoomLevel = 17;
mapView.visibleRegion = region;

I've never used SKMap before, but, yes you can simply obtain the user's location in iOS using CLLocationManager. I assume there's a function in SKMap by which you can zoom to a particular set of coordinates, to which you can simply pass the coordinates obtained from CLLocation Manager.

Related

userLocation so different to CLLocation

I am using CoreLocation to plot my lat/long. This is displayed as Homer in the attached picture (http://i.imgur.com/IRRwOS0.png). I have kCLLocationAccuracyBest set:
self.locMgr.distanceFilter = kCLDistanceFilterNone;
self.locMgr.desiredAccuracy = kCLLocationAccuracyBest;
When I enable userLocation on the map (blue dot) there appears to be a pretty big difference between the accuracies. The blue dot is alot more accurate to my actual location.
How can I improve CoreLocations accuracy to position my MKAnnotations closers to my actual location?
Why am I getting this inaccuracy? userLocation is wifi based while Homer is GPS?
Screenshot:
Implement mapView:didUpdateUserLocation and, within that, set your annotation location to equal the mapView's userLocation.
I'm not entirely sure, but I assume it's probably due to mapview using a private framework for location.
China offsets the GPS for annotations other then users current location. More information can be found here:
http://www.sinosplice.com/life/archives/2013/07/16/a-more-complete-ios-solution-to-the-china-gps-offset-problem

Mapbox - zoomWithLatitudeLongitudeBoundsSouthWest not zooming to correct location

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
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.
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.

how to get latitude and longitude by view coordinates?

I am developing iPhone app and using google map. I used UIView for drawing region. Now I have implemented the touch event methods so how can i get longitude and latitude by view coordinates where user click on view??
As I understand your question You need to create MKMapView that will give you the map property.
https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html
Have you tried with - (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view.
It converts the specified points to coordinates point.
CLLocationCoordinate2D touchCoords = [self convertPoint:TOUCH_POINT toCoordinateFromView:YOUR_VIEW];

RMMapView map set region

I have to set my offline map that has been constructed with tilemill centralized on a custom point. Although i did not find a method like setRegion for MKMapView to make this job for me. Is there any way to set region to a rmmapview map?
no, regions like in ios are not available in route-map. you can set constraints, so that the user cant scroll out of your map:
// Constrain our map so the user can only browse through our exported map tiles
[self.mapView setConstraintsSW:CLLocationCoordinate2DMake(self.mapSrc.bottomRightOfCoverage.latitude, self.mapSrc.topLeftOfCoverage.longitude)
NE:CLLocationCoordinate2DMake(self.mapSrc.topLeftOfCoverage.latitude, self.mapSrc.bottomRightOfCoverage.longitude)];
and of course scrolling to specific position:
[self.mapView moveToLatLong:self.currentPosition.coordinate];
I solve my issue with the code below:
CLLocationCoordinate2D centerOfMap = CLLocationCoordinate2DMake(latitude, longitude);
[mapView setCenterCoordinate:centerOfMap];
With this way i have every time my map centralized to the point that i want.
Also,someone can adjust the zoom of the map and reach the result that he wants.

MKMapView show extra zoomed region. How?

I need to show very small area (30x30 meters) on MKMapView. Setting appropriate region or visibleMapRect doesn't work. MapView shows much bigger region.
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([centerLocation coordinate], 30, 30);
[mapView setRegion:region];
It seems with extra small regions MapView corrects with regionThatFits method before update map.
Manually zoom allows displaying such region.
MapKit is not really designed for such high-zoom indoor uses. You may want to check out alternatives such as the open source MapBox iOS SDK, which has been used for indoor applications. In particular iOS 7's iBeacons technology as well may be useful to you for indoor triangulation and higher accuracy than something like GPS, which was neither designed for indoor nor high-zoom use.
According to Apple docs:
When setting a new region, the map may adjust the value in the region
parameter so that it fits the visible area of the map precisely. This
is normal and is done to ensure that the value in the region property
always reflects the visible portion of the map. However, it does mean
that if you get the value of that property right after calling this
method, the returned value may not match the value you set. (You can
use the regionThatFits: method to determine the region that will
actually be set by the map.)
So, when you apply distance, it creates the region which is best fit for your request. It will not be exactly same as what you have requested.
Also, 30*30 meters is very very high zoom level which might not be supported. Hope it will help.

Resources