Mapbox iOS SDK 2 - Detect click on polygon - ios

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

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

Custom callout view in Mapbox iOS sdk 2.0

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

How to display a MKMapView without street names?

I need to display a map without street names. is it possible using MKMapView ? if not, is there a different map API for iOs that supports this?
thanks,
Nimrod
What you need to do, is to set the maptype to Satellite.
Here's how to do this:
[mapView setMapType:MKMapTypeSatellite];
EDIT:
Not sure if it's satellite, but try one of these:
[mapView setMapType:MKMapTypeStandard];
[mapView setMapType:MKMapTypeHybrid];
[mapView setMapType:MKMapTypeSatellite];
Nimrod, you can't show the map view hiding the street name, only showing the Satellite view. However, check the Google Maps SDK - they just launched it and they provide a lot of thinks that the default MKMapView don't provide.
The MapBox iOS SDK will allow you to customize your map completely, including removing street names, but with MapKit-like functionality.
If you prefer, you can use the Google Maps SDK and make a custom map in this link:
http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html?utm_medium=twitter
And then use the atributes generated in this to custom your map in the app.

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