GLMapView

Objective-C


@interface GLMapView : NSView <CLLocationManagerDelegate>

Swift

class GLMapView : NSView, CLLocationManagerDelegate

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

  • Captures frame from GLMapView to UIImage

    Declaration

    Objective-C

    - (nullable PlatformImage *)captureFrame;

    Swift

    func captureFrame() -> NSImage?

    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;

    Swift

    func captureFrame(whenFinish block: @escaping GLMapCaptureFrameBlock)

    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 BOOL offscreen;

    Swift

    var offscreen: Bool { get set }
  • Rendering frame interval. By default frameInterval is 1 (60 fps)

    Declaration

    Objective-C

    @property NSInteger frameInterval;

    Swift

    var frameInterval: Int { get set }
  • State of tile in center of screen

    Declaration

    Objective-C

    @property (readonly) GLMapTileState centerTileState;

    Swift

    var centerTileState: GLMapTileState { get }

User Interface

User Location

  • Last location received by GLMapView

    Declaration

    Objective-C

    @property (readonly) CLLocation *_Nullable lastLocation;

    Swift

    var lastLocation: CLLocation? { get }
  • Defines if user location is displayed or not. If YES, user location is displayed.

    Declaration

    Objective-C

    @property (nonatomic) BOOL showUserLocation;

    Swift

    var showUserLocation: Bool { get set }
  • Sets alternative user location images.

    Declaration

    Objective-C

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

    Swift

    func setUserLocationImage(_ locationImage: NSImage?, movementImage: NSImage?)

    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.

Style

  • Sets map style

    Declaration

    Objective-C

    - (void)setStyle:(nonnull GLMapVectorCascadeStyle *)style;

    Swift

    func setStyle(_ style: GLMapVectorCascadeStyle)

    Parameters

    style

    Style to set

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

    Declaration

    Objective-C

    - (void)setFontScale:(float)fontScale;

    Swift

    func setFontScale(_ fontScale: Float)
  • Base source of tiles. By default it is vector source

    Declaration

    Objective-C

    @property (copy) GLMapTileSource *_Nonnull base;

    Swift

    @NSCopying var base: GLMapTileSource { get set }
  • Tiles that draws over base tiles

    Declaration

    Objective-C

    @property (copy) NSArray<GLMapTileSource *> *_Nullable overlays;

    Swift

    var overlays: [GLMapTileSource]? { get set }
  • Draw elevation lines. By default is false.

    Declaration

    Objective-C

    @property BOOL drawElevationLines;

    Swift

    var drawElevationLines: Bool { get set }
  • Draw hill shades. By default is false.

    Declaration

    Objective-C

    @property BOOL drawHillshades;

    Swift

    var drawHillshades: Bool { get set }
  • Draw slopes. By default is false.

    Declaration

    Objective-C

    @property BOOL drawSlopes;

    Swift

    var drawSlopes: Bool { get set }
  • Forces reloading of all tiles. Call this function after modifying map style with functions loadStyle*

    Declaration

    Objective-C

    - (void)reloadTiles;

    Swift

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

    Declaration

    Objective-C

    - (void)removeAllTiles;

    Swift

    func removeAllTiles()

Configuring the Map Position

  • 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 CGPoint mapOrigin;

    Swift

    var mapOrigin: CGPoint { get set }
  • Coordinates of the origin point of the map.

    See

    mapOrigin

    Declaration

    Objective-C

    @property GLMapPoint mapCenter;

    Swift

    var mapCenter: GLMapPoint { get set }
  • Coordinates of the origin point of the map.

    See

    mapOrigin

    Declaration

    Objective-C

    @property GLMapGeoPoint mapGeoCenter;

    Swift

    var mapGeoCenter: GLMapGeoPoint { get set }
  • Current zoom of the map view.

    Declaration

    Objective-C

    @property double mapZoom;

    Swift

    var mapZoom: Double { get set }
  • Current zoom level of the map view.

    Declaration

    Objective-C

    @property double mapZoomLevel;

    Swift

    var mapZoomLevel: Double { get set }
  • Maximum possible value of mapZoom. Map won’t zoom closer.

    Declaration

    Objective-C

    @property double maxZoom;

    Swift

    var maxZoom: Double { get set }
  • Map rotation angle form 0° to 360°.

    Declaration

    Objective-C

    @property double mapAngle;

    Swift

    var mapAngle: Double { get set }
  • Captures state of map for search (screenScale, mapCenter, zoom etc)

    Declaration

    Objective-C

    @property (readonly) GLMapViewState *_Nonnull state;

    Swift

    var state: GLMapViewState { get }
  • Starts animation described in block.

    Declaration

    Objective-C

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

    Swift

    func animate(_ animations: (GLMapAnimation) -> Void) -> GLMapAnimation

    Parameters

    animations

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

  • Starts animation described in block.

    Declaration

    Objective-C

    - (nonnull GLMapAnimation *)animate:(nonnull GLMapAnimationBlock)animations
                         withCompletion:
                             (GLMapAnimationCompletionBlock _Nullable)completion;

    Swift

    func animate(_ animations: (GLMapAnimation) -> Void, withCompletion completion: GLMapAnimationCompletionBlock? = nil) -> GLMapAnimation

    Parameters

    animations

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

    completion

    Commpletion block. It’s called when animation ends or cancelled.

  • Starts animation

    Declaration

    Objective-C

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

    Swift

    func start(_ animation: GLMapAnimation)

    Parameters

    animation

    Animation to start.

  • Cancels all map position, zoom and angle animations.

    Declaration

    Objective-C

    - (void)cancelMapAnimations;

    Swift

    func cancelMapAnimations()
  • 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;

    Swift

    func mapZoom(for bbox: GLMapBBox, viewSize size: CGSize) -> Double
  • Calculates map zoom to fit current view.

    Warning

    If bbox size is 0, returns +inf.

    Declaration

    Objective-C

    - (double)mapZoomForBBox:(GLMapBBox)bbox;

    Swift

    func mapZoom(for bbox: GLMapBBox) -> Double
  • Enables clipping of visible map area

    Declaration

    Objective-C

    - (void)enableClipping:(GLMapBBox)bbox
                  minLevel:(float)minLevel
                  maxLevel:(float)maxLevel;

    Swift

    func enableClipping(_ bbox: GLMapBBox, minLevel: Float, maxLevel: Float)

    Parameters

    bbox

    clipping bbox to set

    minLevel

    min zoom level

    maxLevel

    max zoom level

  • Disables clipping of visible map area

    Declaration

    Objective-C

    - (void)disableClipping;

    Swift

    func disableClipping()
  • Checks if clipping is enabled

    Declaration

    Objective-C

    - (BOOL)isClippingEnabled;

    Swift

    func isClippingEnabled() -> Bool

    Return Value

    true if enabled

Converting map coordinates

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

    Declaration

    Objective-C

    - (GLMapPoint)makeMapPointFromDisplayPoint:(CGPoint)displayPoint;

    Swift

    func makeMapPoint(fromDisplay displayPoint: CGPoint) -> GLMapPoint

    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;

    Swift

    func makeMapPoint(fromDisplayDelta displayDelta: CGPoint) -> GLMapPoint

    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
                                   andMapAngle:(double)mapAngle;

    Swift

    func makeMapPoint(fromDisplayDelta displayDelta: CGPoint, andMapZoom mapZoom: Double, andMapAngle mapAngle: Double) -> GLMapPoint

    Parameters

    displayDelta

    The delta you want to convert.

    mapZoom

    Zoom of map

    mapAngle

    Angle 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;

    Swift

    func makeDisplayPoint(from geoPoint: GLMapGeoPoint) -> CGPoint

    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;

    Swift

    func makeGeoPoint(fromDisplay displayPoint: CGPoint) -> GLMapGeoPoint

    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;

    Swift

    func makeDisplayPoint(from mapPoint: GLMapPoint) -> CGPoint

    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;

    Swift

    class func makeMapPoint(from geoPoint: GLMapGeoPoint) -> GLMapPoint

    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;

    Swift

    class func makeGeoPoint(from mapPoint: GLMapPoint) -> GLMapGeoPoint

    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;

    Swift

    func makePixels(fromMeters meters: Double) -> Double

    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;

    Swift

    func makeMeters(fromPixels pixels: Double) -> Double

    Parameters

    pixels

    Distance in pixels

    Return Value

    Distance in meters

  • Converts distance in meters to map coordinates

    Declaration

    Objective-C

    - (double)makeInternalFromMeters:(double)meters;

    Swift

    func makeInternal(fromMeters meters: Double) -> Double

    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;

    Swift

    func makeMeters(fromInternal internal: Double) -> Double

    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;

    Swift

    func makeInternal(fromPixels pixels: Double) -> Double

    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;

    Swift

    func makePixels(fromInternal internal: Double) -> Double

    Parameters

    internal

    Distance in map coordinates

    Return Value

    Distance in pixels

Vector Objects

  • Adds the GLMapDrawObject to the map view.

    Declaration

    Objective-C

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

    Swift

    func add(_ drawObject: GLMapDrawObject)

    Parameters

    drawObject

    object to add

  • Removes previsously added GLMapDrawObject from the map view.

    Declaration

    Objective-C

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

    Swift

    func remove(_ drawObject: GLMapDrawObject)

    Parameters

    drawObject

    object to be removed.

  • Adds or updates area where text (and assisiated icon) must not draw.

    To add 20x20 pt forbidden area around some point on map you should pass offset 10,10 and size 20,20. And forbidden area will be 10 pt to all directions from origin point.

    Declaration

    Objective-C

    - (void)addTextForbiddenArea:(int32_t)name
                          origin:(GLMapPoint)origin
                          offset:(CGPoint)offset
                            size:(CGSize)size;

    Swift

    func addTextForbiddenArea(_ name: Int32, origin: GLMapPoint, offset: CGPoint, size: CGSize)

    Parameters

    name

    unique name for area

    origin

    origin of area

    offset

    offset of area from origin (in points). Axes direction is bottom left.

    size

    size of area (in points).

  • Removes area

    Declaration

    Objective-C

    - (void)removeTextForbiddenArea:(int32_t)name;

    Swift

    func removeTextForbiddenArea(_ name: Int32)

    Parameters

    name

    name of area

  • 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 (strong) GLMapLocaleSettings *_Nonnull localeSettings;

    Swift

    var localeSettings: GLMapLocaleSettings { get set }
  • Defines visible part of map. Usefull interactive objects like balloons.

    Declaration

    Objective-C

    - (PlatformEdgeInsets)visibleMapInsets;

    Swift

    func visibleMapInsets() -> PlatformEdgeInsets