RMMapView map set region - ios

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.

Related

How to zoom to current location on map with Skobbler

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.

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

MkmapView UsersLocation

I am Developing an App which is based on MKMapView, and the requirement of the App is to detect whether the userLocation (represented by Blue dot) is lying on the visible area of the screen or it is outside the visible Screen Area.
In the beginning when map gets loaded, it automatically set it's position to the user's location but I want to detect wether current location is in the visible area of screen or not, after user scroll the map view.
Please provide useful solutions and help me out.
Thanks in advance.
just use userLocationVisible ( I didnt remember but #Volker reminded me)
any annotation:
get the location and check if the pixel coordinate is visible
get the userLocation from the map
get its coordinate
convert it to a mappoint (MKMapPointForCoordinate)
get the mapview's visible mapRect
use MKMapRectContainsPoint
MKMapRect visibleRect = self.mapView.visibleMapRect;
MKMapPoint pt = MKMapPointForCoordinate(self.mapview.userLocation.coordinate);
BOOL visible = MKMapRectContainsPoint(visibleRect, pt);

MKMapView - Is there a way to use MKUserTrackingModeFollow with a modified center/focus?

I have a MapView that takes up the full screen and a few elements toward the top of the screen that overlay the map. These top elements potentially cover the blue location marker.
The map is currently tracking fine with MKUserTrackingModeFollow, but I'd like to move the tracking focus down about an inch (obviously the metric will vary by zoom level) to ensure the marker isn't covered. Is there a way to do this with MKUserTrackingModeFollow?
I've considered moving the map with the top elements, but due to design constraints this isn't an option.
Instead of using the userTrackingMode of the MKMapView object to follow the user's location, you could set up a delegate of CLLocationManager to receive location tracking events, and with each location update event you receive, set the center coordinate of the map view, with your vertical offset added to the coordinate value.
You can use the various Map Kit functions and MKMapView methods to convert your offset from some fraction of the map view's bounds.height to a MKMapPoint or CLLocationDistance value.

MKMapView zooms itself out

This is a small method of mine which takes the location manager's current location and focuses the map just a little bit above it to make room for some other subviews that I've added to the top of the map. If the span's lat/long deltas get too big (more than 1.0), every time the region is set, the span gets bigger and bigger until the map is zoomed out all the way, even without actually touching the map. I think it has something to do with reusing the map view's span, but I don't know exactly what's going on.
- (void)setRegion {
CLLocationCoordinate2D coord = locationManager.location.coordinate;
MKCoordinateSpan span = mapView.region.span;
coord.latitude += 0.002 * (span.latitudeDelta / 0.012523);
MKCoordinateRegion region = MKCoordinateRegionMake(coord, span);
[mapViewGlobal setRegion:region animated:animated];
}
From Apple's docs "If you want to change the center coordinate without changing the zoom level, use the setCenterCoordinate:animated: instead." MKMapView
- (void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated
MKMapView will pick a new region that nicely fits the to a redefined zoom level while still displaying your entire target region and each time yo move north the span changes and things spiral out of control.
Also, your way of working out how much to change the latitude by is a bit odd. Aside from doing a multiple and divide when one would do the trick, it'll only work at a certain latitude (they get stretched away from the equator) and a certain zoom level. You'd be better off working out how many pixels you need the map scrolled by (presumably half the height of your subviews) and then using this function to work out where you need to center the map.
- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view
Another way would be to put the subviews outside of the MKMapView, but that'll affect your aesthetics.

Resources