GLMapView


@interface GLMapView : UIView <CLLocationManagerDelegate>

GLMapView is a custom UIView that renders and presents vector map.

  • Captures frame from GLMapView to UIImage

    Declaration

    Objective-C

    - (nullable UIImage *)captureFrame;

    Return Value

    Current state of the GLMapView

  • Captures frame from GLMapView to UIImage when all load operations will finish.

    See

    offscreen

    Declaration

    Objective-C

    - (void)captureFrameWhenFinish:(nonnull GLMapCaptureFrameBlock)block;

    Parameters

    block

    Block callback is called when screenshot is ready.

  • Allows to render offscreen frames

    By default offscreen = NO. And GLMapView stop render if there is no superview. But in case you need to capture frames from standalone GLMapView, you need to set offscreen = YES;

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) BOOL offscreen;
  • Rendering frame interval. By default frameInterval is 2 (30 fps)

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) NSInteger frameInterval;
  • State of tile in center of screen

    Declaration

    Objective-C

    @property (readonly, atomic) GLMapTileState centerTileState;
  • Sets mask that defines enabled gestures.

    Use tapGestureBlock and longPressGestureBlock to add your tap and long press handlers.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) GLMapViewGestures gestureMask;
  • tapGestureBlock called for each tap gesture recognized.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic)
        GLMapTapGestureBlock _Nullable tapGestureBlock;
  • longPressGestureBlock called for each long press gesture recognized.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic)
        GLMapTapGestureBlock _Nullable longPressGestureBlock;
  • bboxChangedBlock called when map is moved or zoomed.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic)
        GLMapBBoxChangedBlock _Nullable bboxChangedBlock;
  • mapDidMoveBlock called when animation or deceleration ends.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic)
        GLMapBBoxChangedBlock _Nullable mapDidMoveBlock;
  • visibleTilesChangedBlock called when set of visible tiles is changed.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic)
        GLMapVisibleTilesChangedBlock _Nullable visibleTilesChangedBlock;
  • tileErrorBlock called when empty tile without data becomes visible.

    This method is used to show custom data inside empty tiles.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic) GLMapTileErrorBlock _Nullable tileErrorBlock;
  • centerTileStateChangedBlock called when centerTileState is changed

    Declaration

    Objective-C

    @property (readwrite, copy, atomic)
        dispatch_block_t _Nullable centerTileStateChangedBlock;
  • Bounding box of the map

    Declaration

    Objective-C

    @property (readonly, atomic) GLMapBBox bbox;
  • Sets position of map attribution.

    Declaration

    Objective-C

    - (void)setAttributionPosition:(GLMapPlacement)position;

    Parameters

    position

    Position to set.

  • Sets text at the bottom of ruler.

    It’s used to display map center coordinates or any other useful information

    Declaration

    Objective-C

    - (void)setScaleRulerBottomText:(NSString *_Nullable)text;
  • Sets style of the scale ruler.

    //Sets scale ruler position to the bottom center part of screen. And width to half of screen width
    [_mapView setScaleRulerUnits:[AppSettings settings].units placement:GLMapPlacement_BottomLeft paddings:CGPointMake(5, 5) maxWidth:300];
    

    Declaration

    Objective-C

    - (void)setScaleRulerStyle:(GLUnitSystem)unitSystem
                     placement:(GLMapPlacement)placement
                      paddings:(CGPoint)paddings
                      maxWidth:(float)maxWidth;

    Parameters

    unitSystem

    Unit system used by scale ruler

    placement

    placement of text

    paddings

    paddings of scale ruler

    maxWidth

    maxWidth of scale hit in points

  • Sets block that called when ruler value is updated. Block allows to translate units and use custom digit format inside ruler.

    Declaration

    Objective-C

    - (void)setScaleRulerTextFormatterBlock:
        (nonnull GLMapScaleRulerTextFormatterBlock)block;

    Parameters

    block

    New text formatter block

  • Last location received by GLMapView

    Declaration

    Objective-C

    @property (readonly, atomic) CLLocation *_Nullable lastLocation;
  • Defines if user location is displayed or not. If YES, user location is displayed.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL showUserLocation;
  • Sets alternative user location images.

    Declaration

    Objective-C

    - (void)setUserLocationImage:(UIImage *_Nullable)locationImage
                   movementImage:(UIImage *_Nullable)movementImage;

    Parameters

    locationImage

    new user location image. If nil, old image is left unchanged.

    movementImage

    new user movement image. If nil, old image is left unchanged.

  • Loads map style.

    By default GLMapView tries to load [[NSBundle mainBundle] pathForResource:@"DefaultStyle" ofType:@"bundle"];

    Declaration

    Objective-C

    - (BOOL)loadStyleFromBundle:(nonnull NSBundle *)styleBundle;

    Parameters

    styleBundle

    Bundle object with Style.mapcss and images

    Return Value

    Returns YES if style is loaded without errors

  • Loads map style and collects resources from all paths.

    First it tries to find resource in first path, then in second and so on.

    When resouces is loaded you could use it in GLMapVectorStyle and in GLMapVectorCascadeStyle just by name.

    Typically you should call this function with DefaultStyle.bundle path in first place and your resouces path after it. But you could also put your path first, and replace resouces from default style with yours.

    Declaration

    Objective-C

    - (BOOL)loadStyleFromPaths:(nonnull NSArray<NSString *> *)paths;

    Parameters

    paths

    Resource paths array

    Return Value

    Returns YES if style is loaded without errors

  • Allows to modify way framework loads map resources.

    Usually it looks into map style bundle contents, but it’s possible to have all resoureces merged together into one file or even generated programmatically

    Declaration

    Objective-C

    - (BOOL)loadStyleWithBlock:(nonnull GLMapResourceBlock)resourceBlock;

    Parameters

    resourceBlock

    Block that returns style data

    Return Value

    YES if style is loaded without errors

  • Sets scale of font loaded frrom styleBundle. By default fontScale is 1.0

    Declaration

    Objective-C

    - (void)setFontScale:(float)fontScale;
  • Custom raster tile sources. By default mapView have no raster layers.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic)
        NSArray<GLMapRasterTileSource *> *_Nonnull rasterTileSources;
  • Returns set of names of map options defined in map style.

    For example in selector

    node|z17-[_optOn=Bar][amenity=bar],
    

    part [_optOn=Bar] requires option Bar enabled. By default all options is enabled. But you can manage enabled options via setEnabledStyleOptions:

    See

    setEnabledStyleOptions:

    Declaration

    Objective-C

    - (NSSet<NSString *> *_Nullable)getStyleOptions;
  • Sets list of enabled style options

    Declaration

    Objective-C

    - (void)setEnabledStyleOptions:(nonnull NSSet<NSString *> *)opts;

    Parameters

    opts

    Set of enabled options

  • Forces reloading of all tiles

    Declaration

    Objective-C

    - (void)reloadTiles;
  • Removes all tiles. Useful to reduce memory usage in background mode

    Declaration

    Objective-C

    - (void)removeAllTiles;
  • Starts animation

    Declaration

    Objective-C

    - (void)startAnimation:(nonnull GLMapAnimation *)animation;

    Parameters

    animation

    Animation to start.

  • Origin point of the map coordinate system (X, Y).

    Changing the values in this property between 0 and 1 in relative coordinates describes the point of GLMapView which is considered as a center point for mapCenter and setMapCenter:animated:.

    See

    mapCenter, setMapCenter:

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) CGPoint mapOrigin;
  • Coordinates of the origin point of the map.

    See

    mapOrigin

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) GLMapPoint mapCenter;
  • Coordinates of the origin point of the map.

    See

    mapOrigin

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) GLMapGeoPoint mapGeoCenter;
  • Current zoom of the map view.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) double mapZoom;
  • Current zoom level of the map view.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) double mapZoomLevel;
  • Maximum possible value of mapZoom. Map won’t zoom closer.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) double maxZoom;
  • Map rotation angle form 0° to 360°.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) double mapAngle;
  • Starts animation described in block.

    Declaration

    Objective-C

    - (nonnull GLMapAnimation *)animate:(nonnull GLMapAnimationBlock)animations;

    Parameters

    animations

    Block with animations. You could set animation params using block param.

  • Calculates map zoom to fit bbox in view with given size.

    Warning

    If bbox size is 0, returns +inf.

    Declaration

    Objective-C

    - (double)mapZoomForBBox:(GLMapBBox)bbox viewSize:(CGSize)size;
  • Calculates map zoom to fit current view.

    Warning

    If bbox size is 0, returns +inf.

    Declaration

    Objective-C

    - (double)mapZoomForBBox:(GLMapBBox)bbox;
  • Converts a point on the screen to an internal map coordinate.

    Declaration

    Objective-C

    - (GLMapPoint)makeMapPointFromDisplayPoint:(CGPoint)displayPoint;

    Parameters

    displayPoint

    The point you want to convert.

    Return Value

    The internal map coordinate of the specified point.

  • Converts a distance between two points on the screen to an internal map coordinate at current map zoom.

    Declaration

    Objective-C

    - (GLMapPoint)makeMapPointFromDisplayDelta:(CGPoint)displayDelta;

    Parameters

    displayDelta

    The delta you want to convert.

    Return Value

    The delta in internal map coordinates.

  • Converts a distance between two points on the screen to an internal map coordinate.

    Declaration

    Objective-C

    - (GLMapPoint)makeMapPointFromDisplayDelta:(CGPoint)displayDelta
                                    andMapZoom:(double)mapZoom;

    Parameters

    displayDelta

    The delta you want to convert.

    mapZoom

    Zoom of map

    Return Value

    The delta in internal map coordinates.

  • Converts a geo point to the point on the screen.

    Declaration

    Objective-C

    - (CGPoint)makeDisplayPointFromGeoPoint:(GLMapGeoPoint)geoPoint;

    Parameters

    geoPoint

    The geo point you want to convert.

    Return Value

    Coresponding point on the screen.

  • Converts a point on the screen to the geo point.

    Declaration

    Objective-C

    - (GLMapGeoPoint)makeGeoPointFromDisplayPoint:(CGPoint)displayPoint;

    Parameters

    displayPoint

    Point on screen you want to convert.

    Return Value

    Coresponding geo point.

  • Converts an internal map coordinate to the point on the screen.

    Declaration

    Objective-C

    - (CGPoint)makeDisplayPointFromMapPoint:(GLMapPoint)mapPoint;

    Parameters

    mapPoint

    The map point you want to convert.

    Return Value

    Coresponding point on the screen.

  • Converts geo coordinates to the internal point.

    Declaration

    Objective-C

    + (GLMapPoint)makeMapPointFromGeoPoint:(GLMapGeoPoint)geoPoint;

    Parameters

    geoPoint

    Geo point you want to convert.

    Return Value

    Corresponding point in map coordinates.

  • Converts an internal point to geo coordinates.

    Declaration

    Objective-C

    + (GLMapGeoPoint)makeGeoPointFromMapPoint:(GLMapPoint)mapPoint;

    Parameters

    mapPoint

    Point in map coordinates.

    Return Value

    Corresponding point in geo coordinates.

  • Converts distance in meters to pixels on the screen

    Declaration

    Objective-C

    - (double)makePixelsFromMeters:(double)meters;

    Parameters

    meters

    Distance in meters

    Return Value

    Distance in pixels

  • Converts distance in pixels on the screen to meters

    Declaration

    Objective-C

    - (double)makeMetersFromPixels:(double)pixels;

    Parameters

    pixels

    Distance in pixels

    Return Value

    Distance in meters

  • Converts distance in meters to map coordinates

    Declaration

    Objective-C

    - (double)makeInternalFromMeters:(double)meters;

    Parameters

    meters

    Distance in meters

    Return Value

    Distance in map coordinates

  • Converts distance in map coordinates to meters

    Declaration

    Objective-C

    - (double)makeMetersFromInternal:(double)internal;

    Parameters

    internal

    Distance in map coordinates

    Return Value

    Distance in meters

  • Converts distance in pixels to map coordinates

    Declaration

    Objective-C

    - (double)makeInternalFromPixels:(double)pixels;

    Parameters

    pixels

    Distance in pixels

    Return Value

    Distance in map coordinates

  • Converts distance in map coordinates to pixels

    Declaration

    Objective-C

    - (double)makePixelsFromInternal:(double)internal;

    Parameters

    internal

    Distance in map coordinates

    Return Value

    Distance in pixels

  • Adds the GLMapDrawObject to the map view.

    Declaration

    Objective-C

    - (void)add:(nonnull GLMapDrawObject *)drawObject;

    Parameters

    drawObject

    object to add

  • Removes previsously added GLMapDrawObject from the map view.

    Declaration

    Objective-C

    - (void)remove:(nonnull GLMapDrawObject *)drawObject;

    Parameters

    drawObject

    object to be removed.

  • Removes all previsously added tracks from the map view.

    Declaration

    Objective-C

    - (void)removeAllTracks;
  • Map locale settings

    Set of supported locales is returned by [GLMapLocaleSettings supportedLocales]

    E.g. to set map languages priority to English, Deutsch, native

    [_mapView setLocaleSettings:[[GLMapLocaleSettings alloc] initWithLocalesOrder:@[@"en", @"de", @"native"]]];
    // Then reload tiles to apply new locale settings
    [_mapView reloadTiles];
    

    Default value is supported languages from [NSLocale preferredLanguages]

    Declaration

    Objective-C

    @property (readwrite, strong, atomic)
        GLMapLocaleSettings *_Nonnull localeSettings;