| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- //
- // GMSMapView.h
- // Google Maps SDK for iOS
- //
- // Copyright 2012 Google Inc.
- //
- // Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
- // Service: https://developers.google.com/maps/terms
- //
- #import <CoreLocation/CoreLocation.h>
- #import <UIKit/UIKit.h>
- #import <GoogleMaps/GMSMapLayer.h>
- #import <GoogleMaps/GMSUISettings.h>
- #ifndef __GMS_AVAILABLE_BUT_DEPRECATED
- #define __GMS_AVAILABLE_BUT_DEPRECATED __deprecated
- #endif
- @class GMSCameraPosition;
- @class GMSCameraUpdate;
- @class GMSCoordinateBounds;
- @class GMSIndoorDisplay;
- @class GMSMapLayer;
- @class GMSMapView;
- @class GMSMarker;
- @class GMSOverlay;
- @class GMSProjection;
- /** Delegate for events on GMSMapView. */
- @protocol GMSMapViewDelegate <NSObject>
- @optional
- /**
- * Called before the camera on the map changes, either due to a gesture,
- * animation (e.g., by a user tapping on the "My Location" button) or by being
- * updated explicitly via the camera or a zero-length animation on layer.
- *
- * @param gesture If YES, this is occuring due to a user gesture.
- */
- - (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture;
- /**
- * Called repeatedly during any animations or gestures on the map (or once, if
- * the camera is explicitly set). This may not be called for all intermediate
- * camera positions. It is always called for the final position of an animation
- * or gesture.
- */
- - (void)mapView:(GMSMapView *)mapView
- didChangeCameraPosition:(GMSCameraPosition *)position;
- /**
- * Called when the map becomes idle, after any outstanding gestures or
- * animations have completed (or after the camera has been explicitly set).
- */
- - (void)mapView:(GMSMapView *)mapView
- idleAtCameraPosition:(GMSCameraPosition *)position;
- /**
- * Called after a tap gesture at a particular coordinate, but only if a marker
- * was not tapped. This is called before deselecting any currently selected
- * marker (the implicit action for tapping on the map).
- */
- - (void)mapView:(GMSMapView *)mapView
- didTapAtCoordinate:(CLLocationCoordinate2D)coordinate;
- /**
- * Called after a long-press gesture at a particular coordinate.
- *
- * @param mapView The map view that was pressed.
- * @param coordinate The location that was pressed.
- */
- - (void)mapView:(GMSMapView *)mapView
- didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate;
- /**
- * Called after a marker has been tapped.
- *
- * @param mapView The map view that was pressed.
- * @param marker The marker that was pressed.
- * @return YES if this delegate handled the tap event, which prevents the map
- * from performing its default selection behavior, and NO if the map
- * should continue with its default selection behavior.
- */
- - (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker;
- /**
- * Called after a marker's info window has been tapped.
- */
- - (void)mapView:(GMSMapView *)mapView
- didTapInfoWindowOfMarker:(GMSMarker *)marker;
- /**
- * Called after an overlay has been tapped.
- * This method is not called for taps on markers.
- *
- * @param mapView The map view that was pressed.
- * @param overlay The overlay that was pressed.
- */
- - (void)mapView:(GMSMapView *)mapView didTapOverlay:(GMSOverlay *)overlay;
- /**
- * Called when a marker is about to become selected, and provides an optional
- * custom info window to use for that marker if this method returns a UIView.
- * If you change this view after this method is called, those changes will not
- * necessarily be reflected in the rendered version.
- *
- * The returned UIView must not have bounds greater than 500 points on either
- * dimension. As there is only one info window shown at any time, the returned
- * view may be reused between other info windows.
- *
- * Removing the marker from the map or changing the map's selected marker during
- * this call results in undefined behavior.
- *
- * @return The custom info window for the specified marker, or nil for default
- */
- - (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker;
- /**
- * Called when mapView:markerInfoWindow: returns nil. If this method returns a
- * view, it will be placed within the default info window frame. If this method
- * returns nil, then the default rendering will be used instead.
- *
- * @param mapView The map view that was pressed.
- * @param marker The marker that was pressed.
- * @return The custom view to disaply as contents in the info window, or null to
- * use the default content rendering instead
- */
- - (UIView *)mapView:(GMSMapView *)mapView markerInfoContents:(GMSMarker *)marker;
- /**
- * Called when dragging has been initiated on a marker.
- */
- - (void)mapView:(GMSMapView *)mapView didBeginDraggingMarker:(GMSMarker *)marker;
- /**
- * Called after dragging of a marker ended.
- */
- - (void)mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker;
- /**
- * Called while a marker is dragged.
- */
- - (void)mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker;
- /**
- * Called when the My Location button is tapped.
- *
- * @return YES if the listener has consumed the event (i.e., the default behavior should not occur),
- * NO otherwise (i.e., the default behavior should occur). The default behavior is for the
- * camera to move such that it is centered on the user location.
- */
- - (BOOL)didTapMyLocationButtonForMapView:(GMSMapView *)mapView;
- @end
- /**
- * Display types for GMSMapView.
- */
- typedef enum {
- /** Basic maps. The default. */
- kGMSTypeNormal = 1,
- /** Satellite maps with no labels. */
- kGMSTypeSatellite,
- /** Terrain maps. */
- kGMSTypeTerrain,
- /** Satellite maps with a transparent label overview. */
- kGMSTypeHybrid,
- /** No maps, no labels. Display of traffic data is not supported. */
- kGMSTypeNone,
- } GMSMapViewType;
- /**
- * This is the main class of the Google Maps SDK for iOS and is the entry point
- * for all methods related to the map.
- *
- * The map should be instantiated via the convenience constructor
- * [GMSMapView mapWithFrame:camera:]. It may also be created with the default
- * [[GMSMapView alloc] initWithFrame:] method (wherein its camera will be set to
- * a default location).
- *
- * GMSMapView can only be read and modified from the main thread, similar to all
- * UIKit objects. Calling these methods from another thread will result in an
- * exception or undefined behavior.
- */
- @interface GMSMapView : UIView
- /** GMSMapView delegate. */
- @property(nonatomic, weak) IBOutlet id<GMSMapViewDelegate> delegate;
- /**
- * Controls the camera, which defines how the map is oriented. Modification of
- * this property is instantaneous.
- */
- @property(nonatomic, copy) GMSCameraPosition *camera;
- /**
- * Returns a GMSProjection object that you can use to convert between screen
- * coordinates and latitude/longitude coordinates.
- *
- * This is a snapshot of the current projection, and will not automatically
- * update when the camera moves. It represents either the projection of the last
- * drawn GMSMapView frame, or; where the camera has been explicitly set or the
- * map just created, the upcoming frame. It will never be nil.
- */
- @property(nonatomic, readonly) GMSProjection *projection;
- /**
- * Controls whether the My Location dot and accuracy circle is enabled.
- * Defaults to NO.
- */
- @property(nonatomic, assign, getter=isMyLocationEnabled) BOOL myLocationEnabled;
- /**
- * If My Location is enabled, reveals where the user location dot is being
- * drawn. If it is disabled, or it is enabled but no location data is available,
- * this will be nil. This property is observable using KVO.
- */
- @property(nonatomic, strong, readonly) CLLocation *myLocation;
- /**
- * The marker that is selected. Setting this property selects a particular
- * marker, showing an info window on it. If this property is non-nil, setting
- * it to nil deselects the marker, hiding the info window. This property is
- * observable using KVO.
- */
- @property(nonatomic, strong) GMSMarker *selectedMarker;
- /**
- * Controls whether the map is drawing traffic data, if available. This is
- * subject to the availability of traffic data. Defaults to NO.
- */
- @property(nonatomic, assign, getter=isTrafficEnabled) BOOL trafficEnabled;
- /**
- * Controls the type of map tiles that should be displayed. Defaults to
- * kGMSTypeNormal.
- */
- @property(nonatomic, assign) GMSMapViewType mapType;
- /**
- * Minimum zoom (the farthest the camera may be zoomed out). Defaults to
- * kGMSMinZoomLevel. Modified with -setMinZoom:maxZoom:.
- */
- @property(nonatomic, assign, readonly) float minZoom;
- /**
- * Maximum zoom (the closest the camera may be to the Earth). Defaults to
- * kGMSMaxZoomLevel. Modified with -setMinZoom:maxZoom:.
- */
- @property(nonatomic, assign, readonly) float maxZoom;
- /**
- * If set, 3D buildings will be shown where available. Defaults to YES.
- *
- * This may be useful when adding a custom tile layer to the map, in order to
- * make it clearer at high zoom levels. Changing this value will cause all
- * tiles to be briefly invalidated.
- */
- @property(nonatomic, assign, getter=isBuildingsEnabled) BOOL buildingsEnabled;
- /**
- * Sets whether indoor maps are shown, where available. Defaults to YES.
- *
- * If this is set to NO, caches for indoor data may be purged and any floor
- * currently selected by the end-user may be reset.
- */
- @property(nonatomic, assign, getter=isIndoorEnabled) BOOL indoorEnabled;
- /**
- * Gets the GMSIndoorDisplay instance which allows to observe or control
- * aspects of indoor data display.
- */
- @property(nonatomic, strong, readonly) GMSIndoorDisplay *indoorDisplay;
- /**
- * Gets the GMSUISettings object, which controls user interface settings for the
- * map.
- */
- @property(nonatomic, strong, readonly) GMSUISettings *settings;
- /**
- * Controls the 'visible' region of the view. By applying padding an area
- * arround the edge of the view can be created which will contain map data
- * but will not contain UI controls.
- *
- * If the padding is not balanced, the visual center of the view will move as
- * appropriate. Padding will also affect the |projection| property so the
- * visible region will not include the padding area. GMSCameraUpdate
- * fitToBounds will ensure that both this padding and any padding requested
- * will be taken into account.
- *
- * This property may be animated within a UIView-based animation block.
- */
- @property(nonatomic, assign) UIEdgeInsets padding;
- /**
- * Defaults to YES. If set to NO, GMSMapView will generate accessibility
- * elements for overlay objects, such as GMSMarker and GMSPolyline.
- *
- * This property is as per the informal UIAcessibility protocol, except for the
- * default value of YES.
- */
- @property(nonatomic) BOOL accessibilityElementsHidden;
- /**
- * Accessor for the custom CALayer type used for the layer.
- */
- @property(nonatomic, readonly, retain) GMSMapLayer *layer;
- /**
- * Builds and returns a GMSMapView, with a frame and camera target.
- */
- + (instancetype)mapWithFrame:(CGRect)frame camera:(GMSCameraPosition *)camera;
- /**
- * Tells this map to power up its renderer. This is optional and idempotent.
- *
- * This method is obsolete and deprecated and will be removed in a future release.
- */
- - (void)startRendering __GMS_AVAILABLE_BUT_DEPRECATED;
- /**
- * Tells this map to power down its renderer. This is optional and idempotent.
- *
- * This method is obsolete and deprecated and will be removed in a future release.
- */
- - (void)stopRendering __GMS_AVAILABLE_BUT_DEPRECATED;
- /**
- * Clears all markup that has been added to the map, including markers,
- * polylines and ground overlays. This will not clear the visible location dot
- * or reset the current mapType.
- */
- - (void)clear;
- /**
- * Sets |minZoom| and |maxZoom|. This method expects the minimum to be less than
- * or equal to the maximum, and will throw an exception with name
- * NSRangeException otherwise.
- */
- - (void)setMinZoom:(float)minZoom maxZoom:(float)maxZoom;
- /**
- * Build a GMSCameraPosition that presents |bounds| with |padding|. The camera
- * will have a zero bearing and tilt (i.e., facing north and looking directly at
- * the Earth). This takes the frame and padding of this GMSMapView into account.
- *
- * If the bounds is nil or invalid this method will return a nil camera.
- */
- - (GMSCameraPosition *)cameraForBounds:(GMSCoordinateBounds *)bounds
- insets:(UIEdgeInsets)insets;
- /**
- * Changes the camera according to |update|.
- * The camera change is instantaneous (with no animation).
- */
- - (void)moveCamera:(GMSCameraUpdate *)update;
- @end
- /**
- * Accessibility identifier for the compass button.
- */
- extern NSString *const kGMSAccessibilityCompass;
- /**
- * Accessibility identifier for the "my location" button.
- */
- extern NSString *const kGMSAccessibilityMyLocation;
|