Custom callout view in Mapbox iOS sdk 2.0 - ios

I am using Mapbox iOS SDK. I installed it using cocoapods. I need to create a custom callout view and to do so I found below method in the previous SDK version 1.x.x.
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
And current SDK version is 2.0 where they change the protocol name from RMMapViewDelegate to MGLMapViewDelegate, now the problem is I am not able to find the alternate method for layerForAnnotation in this new protocol. Can anybody suggest me what to do.

Currently, you can't supply a custom view/layer as in 1.x.x, but you can provide custom imagery.
- (nullable MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id<MGLAnnotation>)annotation;
Watch this space for proper views:
https://github.com/mapbox/mapbox-gl-native/issues/1784

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

Disable panning while zooming

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

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

setNeedsDisplayInMapRect - Deprecated iOS7

I am currently trying the Apple example Breadcrumb to track and draw a path where the user has been.
Having updated the base SDK to 7, it is alerting me that setNeedsDisplayInMapRect is deprecated as of iOS 7.
I have looked in the reference documents and they advise that this should be replaced with MKOverlayRenderer.
As this is all new to me, I am struggling to fully grasp how to swap this around. Does anyone have any experience with this and can explain how to do so?
Change CrumPathView parent class to MKOverlayRenderer (available iOS 7.0 onwards) from MKOverlayView (deprecated on iOS 7.0) as both classes expose the same methods with couple of new extra methods introduced in MKOverlayRenderer.
Implement following MKMapViewDelegate's method (available in iOS 7.0 onwards) as a replacement for deprecated
// Deprecated in iOS 7.0
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
// Method to replace above deprecated method (available in iOS 7.0)
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id < MKOverlay >)overlay

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