Disable panning while zooming - ios

I switched from google maps api for iOS to here maps api for iOS . I would like to disable panning/scrolling of map while zooming in order to keep gps location of centre point same. Any suggestion? Thanks in advance.

You could use
[MPAMapView disableMapGestures:] apis to disable panning/scrolling.
Details could be found # https://developer.here.com/mobile-sdks/documentation/ios/topics/map-gestures.html

You can accomplish this use case using a combination of NMAMapGestureDelegate and NMAMapViewDelegate.
For example, you can implement the NMAMapGestureDelegate - (void)mapView:(NMAMapView *)mapView didReceivePinch:(float)pinch atLocation:(CGPoint)location; handler method to add some extra code to disable the gestures you wish to block. And then re-enable the gestures once the pinch gesture has ended.
Something like this should do the trick, you may have to play with the implementation a bit to get it working how you would like:
- (void)mapView:(NMAMapView *)mapView didReceivePinch:(float)pinch atLocation:(CGPoint)location
{
[mapView disableMapGestures:(NMAMapGestureTypePan | NMAMapGestureTypeTwoFingerPan)];
// execute default pinch behaviour
[mapView.defaultGestureHandler mapView:mapView didReceivePinch:pinch atLocation:location];
}
...
- (void)mapViewDidEndMovement:(NMAMapView *)mapView
{
[mapView enableMapGestures:NMAMapGestureTypeAll];
}
You can look at NMAMapView - (NSInteger)respondToEvents:(NSInteger)events withBlock:(NMAMapEventBlock)block as well. It's possible responding to the NMAMapEventGestureEnded event using respondToEvents may work better for your use case.
More Information:
Map Gestures
NMAMapGestureDelegate
NMAMapViewDelegate
Map Event Blocks

Related

Show tint effect when info window is tapped in google Maps

I am creating a InfoWindow by using the following method,
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
And I am handling the event related to tapping of InfoWindow using,
- (void) mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker
But I want to show a tint effect when the InfoWindow is tapped. I want to implement this effect with google maps.This effect can be seen in Apple Maps. In Apple maps if you drop a pin and the tap the InfoWindow it shows the tint effect. I want to implement this feature like Apple maps in google Maps.
Based on the Official Google documention for Google Maps API, it is not possible to customize the infowindow's color however there is a work around for that. What you can do is to insert images as a background to make it tinted.
I found a video tutorial which discuss how to insert images using GMSMa[ViewDelegate: https://www.youtube.com/watch?v=ILiBXYscsyY

Mapbox iOS SDK 2 - Detect click on polygon

I need to recognize which MGLPolygon was selected by user on Mapbox 2.0 map.
- (void)mapView:(MGLMapView *)mapView didSelectAnnotation:(id <MGLAnnotation>)annotation
doesn't work.
How can I customize MGLPolygon to make it clickable?
This functionality isn't supported yet: https://github.com/mapbox/mapbox-gl-native/issues/2082

How to determine when mapview zoom level has changed using Mapbox-iOS-SDK?

I am using Mapbox-iOS-SDK 2.1.2 and I need to know when the user changes zoom level on the map view. I know how to get the current zoom level, but I don't see any delegate methods for determining when the zoom level actually changed.
My reason is I am trying to mimic the scale dependencies functionality found in ESRI, and I only want to display annotations for records in the local data store when the zoom level is 15+.
Does anyone know if Mapbox supports notification when the zoom level has changed?
Or, does Mapbox support scale dependencies? If it does and I'm missing it, please let me know as that would save me from rolling my own version.
You can check if zoomLevel was changed in delegate method
(void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated
https://www.mapbox.com/ios-sdk/api/Protocols/MGLMapViewDelegate.html#//api/name/mapView:regionDidChangeAnimated:

Customize user location tint on iOS

I'm trying to change the color of the user location, as it is done in the "find my friends" app by Apple (see attached screenshot).
Note that I'm using the MapBox SDK, and I currently have the following method:
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation)
return nil;
}
I also looked into this thread to have an idea about how I should do something similar, but didn't find the same code for user location. Did Apple use a static PNG picture for Find my friends? Will I lose the adaptive circle around the position by changing it to another color (if that's even possible)?
UPDATE
As #Incanus said in his reply, in my -[RMMapViewDelegate mapView:layerForAnnotation:] callback method, I should get three calls corresponding to isUserLocationAnnotation = YES -- the dot, the accuracy circle, and the pulsing halo.
I only get one, and I don't get why.
Also, I tried to customise the annotation when the tracking mode changes, here's what I did:
if (self.mMapView.userTrackingMode == RMUserTrackingModeNone)
{
for (RMAnnotation *annotation in self.mMapView.annotations) {
if (annotation.isUserLocationAnnotation) {
if ([annotation.annotationType isEqualToString:#"RMAccuracyCircleAnnotation"]) {
[(RMCircle*)annotation.layer setFillColor:[[UIColor redColor] colorWithAlphaComponent:0.6]];
[(RMCircle*)annotation.layer removeAllAnimations];
}
}
}
[self enableBouncingOnLayer:self.mMapView.userLocation.layer];
}
else
{
[self.mMapView.userLocation.layer removeAnimationForKey:#"animateScale"];
}
So far so good, I get the blue accuracy circle to turn red and stop changing size.
The problem is, the MapBox framework will still update it, so it will go back to normal.
What's interesting is, using this method, I do have 3 annotation with isUserLocationAnnotation set to YES, but I only get one callback.
Any help appreciated.
In Swift 3,
mapView.tintColor = .red
Wonderfully straight forward now.
For the MapBox SDK, you can access the actual blue dot inside of the resources bundle and create a tinted version, either on the fly with Core Graphics or ahead of time as another resource in your bundle.
In Find My Friends, the dot is still blue -- they are actually just using an altered copy for other annotations. You can do the same.
You might also be interested in https://github.com/0xced/UIKit-Artwork-Extractor specifically for pulling resources out of the Find My Friends app, which is actually what we used on the MapKit framework to get the blue dot for the MapBox SDK ;-)
As Incanus pointed it out, I'm using the layerForAnnotation: method to customize my user annotation.
I then created this method to force an update of the layer, so that it can be drawn again.
- (void)refreshUserAnnotation {
[mUserAnnotation setLayer: [self mapView:mMapView layerForAnnotation:mUserAnnotation]];
}

Google Maps iOS rightCalloutAccessoryView replacement?

Just wondering what's the rightCalloutAccessoryView (the blue button below) replacement in the Google Maps SDK? Or do I need to make a custom view.....
EDIT:
Is there a better option than GMSMapViewDelegate's:
- (void)mapView:(GMSMapView *)mapView
didTapInfoWindowOfMarker:(id<GMSMarker>)marker;?
(it isn't obvious to the user that you can tap the info window...)
EDIT 2
This Plane Finder - Live Flight Status Tracker seems to use default callouts with the iOS SDK: http://bit.ly/PFinder. How do you do that?
Found it! :)
See https://github.com/ryanmaxwell/GoogleMapsCalloutView for an example project :)

Resources