Function for when map is interacted with - ios

I was wondering if there is an inbuilt function that is called whenever a map box map is interacted with?
I’m wondering this because I want to have an image appear whenever the map is moved.
Thanks

Yes, you should use one of the MGLMapViewDelegate methods depending on your requirements:
-mapView:regionWillChangeAnimated:
-mapViewRegionIsChanging:
-mapView:regionDidChangeAnimated:
You can read about their implementation in the MapBox api reference here: Mapbox api

Related

Is it possible to change a route by dragging its polyline in a GMSMapView?

I'm currently working on an app using the latest version of the Google Maps SDK for iOS and I've been wondering if it's possible to achieve the same "drag and drop" feature available in the web version of Google Maps to get a custom route.
After completely reading the official documentation I still haven't found an answer or guidance related to this feature, so any help will be appreciated.
Enabling the drag and drop feature can be done by creating an instance of GMDraggableMarkerManager and sets itself as the delegate in order to be notified of drag events.
Steps given in google-maps-sdk-ios-drag-drop are as follows:
To initialize the drag & drop functionality you have to import
the GMDraggableMarkerManager.h in your UIViewController displaying
the map.
Create a property for the GMDraggableMarkerManager.
After the initialization of the Google Maps View you have to
initialize the draggableMarkerManager.
Please note that to fully implement drag and drop feature, a long press on the marker enables you to drag it around and set it to another position
This SO post -
How to implement GMSMarker drag drop on GMSMapView? might also help.

iOS Custom InfoWindow Google Maps SDK 1.7.2

I have been searching and coding with the Google Maps iOS SDK 1.7.2
I need to build an app that displays custom InfoWindow after the marker is tapped.
Google posted a YouTube Video, that shows how to do it with just ONE marker.
The practical use scenario uses more than ONE marker, but if we follow the example of YouTube Video adding more than one marker, all the markers would show the same info inside the custom InfoWindows.
I did a iOS sample and uploaded to GitHub Sample Here
My Question is: Could anyone download the sample at GitHub and help me to implement that feature, display more than one marker with custom InfoWindow displaying different info for each marker ? In my sample inside the InfoWindow there is a WebView. For my use scenario I would need to load for each marker a different WebView(url) for each marker on the map but I couldn't load the WebView inside the custom InfoWindow. That WebView would be the size of the custom InfoWindow.I would load all the info for the markers as different webpages in the size of the info window.
It also would help a lot of other people that right now can't find a complete and fully working sample of that custom InfoWindow for iOS.
Thanks and Cheers!
Another vote for SMCalloutView. Check out my answer here for a quick start on implementing it.
Sorry to not actually answer your question per se, but Google's rendered UIView info windows are more hassle than they're worth, I think. You may be able to get a webview to load inside one of them, but the Maps SDK takes the custom UIView you set and then renders it into OpenGL, ignoring most (all?) updates you try to make.
Using SMCalloutView skips all of that and we put its view on top of the map, allowing you better control before and after drawing.
SMCalloutView helps you to custom the InfoWindow, you can download the Sample project and run it.
For displaying multiple InfoWindows, you have to treat GoogleMaps SDK (GMSMapView has a #property(nonatomic, strong) GMSMarker *selectedMarker property, which is not a Set), see the Sample project, in mapView:didTapAtMarker: delegate method.

Clicking buildings in Google Maps SDK iOS

How can I make these buildings respond to touch using the Google Map SDK? The points that define the edges of the building are clearly defined, so how can I access this data to determine if a touch has been made inside vs outside of the building.
You cannot do it directly, else you can create GMSOverlay around the area you want an action then can use the Google MapView delegate function
mapView:didTapOverlay:

customizing info window for multiple markers

I have seen the google developers video on custom info window for google maps ios sdk and got it. But how to use it when we have multiple markers. In my application i have to point 10 place and have to use that custom infowindow
I got it, we just have to call the customInfoWindow class how many time we want with new set of parameters.
Not sure exactly if this is what the question was - but you can attach a piece of your own data to the marker using marker.userData. You can make this anything you want - an NSDictionary for example. In -markerInfoWindow:(GMSMarker *marker) you can retrieve the userData and based on that, you can decide what view you want to return. Make sure the userData contains sufficient data to decide what your view should contain and you are good to go.

iOS Google Maps Api Tiled Overlays

My app currently is using the google maps api v2 for iOS. I would like to add custom tiled overlays, which I realize is not support by the api.
The first approach I took to this problem was to try to extend the GMSOverlay class but I later found that the drawLayer method was never being called.
Next, I tried having my custom class extend UIView and then add my class as a subview to the map view. I was able to use the GMSMapViewDelegate method didChangeCameraPosition to report camera updates back to my custom class so that the tiles could be redrawn. This mostly worked with a couple exceptions, first, only the initial set of tiles would load, and if you panned or zoomed from the initial X,Y,Z the map tiles would not update via the drawInRect method. The second problem was that my custom UIView was covering all the markers and their corresponding callouts after tapping.
My question is, does anyone having any experience adding custom tiles or subclassing the GMSOverlay class to add, for example, custom weather tiles over top of the google map?
Good news from the release notes of v. 1.3.0 of Google Maps SDK for iOS (released today):
Support for custom tile overlays (image-based) via GMSTileLayer.
See: https://developers.google.com/maps/documentation/ios/releases
Have you tried looking at this example?
https://github.com/mtigas/iOS-MapLayerDemo
It is based on the MKMapKit, not the Google-Map SDK. It supports tiles with zoom and is very easy to extend, and might point you in the right direction.
If you need to generate tiles for the map, you can use MapTiler
http://www.maptiler.org/
The Windows version of MapTiler gives more fine grained control of the tile generation.

Resources