I have a mapView:regionDidChangeAnimated: delegate method that is called at the beginning of the app when MKMapView is loaded. How can I stop it from being called right away? I don't mind it being called when user drags the map, but just not when mapview is loaded.
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
Related
I have a GMSMapView with a lot of markers, every marker represents one store of my client, every time the user approaches to one of the markers (to one of the stores) he gets a notification with the address of the store.
I want that when the user taps on a notification (opens the app via notification) the marker will be presented on the map (already selected).
Note: the marker is a property for every Store object, the UILocalNotification stores the Store object's identifier and that's how I find the correct store.
Note 2: I'm working with Google Maps iOS SDK.
I've tried to do it like this:
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
NSString *storeIdentifier=[[notification userInfo] objectForKey:#"storeIdentifier"];
Store *notificationsStore=[self.monitorLocationVC storeForIdentifier:storeIdentifier];
[self.myVC mapView:self.myVC.mapView didTapMarker:notificationsStore.marker];
}
For some reason, the marker isn't being selected when the user opens the app.
I've override mapView: didTapMarker: on myVC.m like that:
-(BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
return NO;
}
didTapMarker is on GMSMapViewDelegate, it's called by the map to notify your code that the marker has been tapped. It doesn't tap the marker.
You can however set selectedMarker on the map view, to cause that marker to be selected, and to show its info window (if it has one). For example:
self.myVC.mapView.selectedMarker = notificationsStore.marker;
See here for more examples: How to show a Info window in iOS Google maps without tapping on Marker?
-(BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
viewIwant.hidden=NO;
//or any nib you want
return YES;
}
I am unable to call
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
On following IBAction
- (IBAction)button:(UIButton *)sender {
}
help me
-(IBAction)button:(UIButton *)sender {
[self mapView:yourMapViewObject didUpdateUserLocation:yourLactionObject];
}
You Can't explicitly call the delegate method of MKMapView.
It will get called when the location of the user gets updated.
Take a look at apple doc here
So, if you want to call the same action for MKMapView delegate and button selector, create new function which is called from
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
and also which is called from your button selector. You shouldn't call MKMapView delegate method.
We are developing IOS app. Where user can drop pin (Car, Bus etc) on map and define direction (angle) as well. I know how to drop pin but What I need to do for direction angle?
Here are details of my problem. As you can see a pin dropped at may. User can set direction to any angle with his fingers. Like user rotate photo. I need to show pin to other user app users to with exact direction angle. What I need to persist for that at central database or web API end that can be used to place that pin on other user's app.
CLLocationManagerDelegate protocol has a method called - (void)locationManager:didUpdateHeading: in which you can get a hold on users heading aka direction.
Sample:
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
CLLocationDirection direction = newHeading.magneticHeading;
}
NOTE: for this method to be called, you have to call CLLocationManager's instance method - (void)startUpdatingHeading. Like this:
[self.locationManager startUpdatingHeading];
Then if you have a custom view for MKUserLocation annotation you can rotate it based on previously received direction in above method.
Sample:
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
{
// rotated custom view code
}
}
I have a question about MapKit. I set the userTrackingMode property to move the map according to the user position update.
[_mapView setUserTrackingMode:MKUserTrackingModeFollowWithHeading animated:YES];
Is there a way to be alerted when you exit from this mode?
From the Apple Docs on MKMapViewDelegate Protocol:
mapView:didChangeUserTrackingMode:animated:
Tells the delegate that the user tracking mode changed.
(void)mapView:(MKMapView *)mapView didChangeUserTrackingMode:(MKUserTrackingMode)mode animated:(BOOL)animated
When reloading data to show on a MKMapView, the pin will disappear for a minute but then reappear, I have set the self.mapView.showsUserLocation=YES; in several places in my code and I also have this method to try and stop it from vanishing:
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
self.mapView.showsUserLocation=YES;
}
What can cause the user location to disappear?