Code Monkey home page Code Monkey logo

mkzoomlevel's Introduction

version Swift: 5.0+ iOS: 9.0+ macOS: 10.11+ tvOS: 9.2+
Build on Xcode (latest) Build on Xcode (12 beta)
SwiftPM: compatible license contact: @stleamist

MKZoomLevel

MKZoomLevel is an implementation of zoom level getter & setter for MKMapView that works exactly the same as the private _zoomLevel property without resetting the camera angle.

Features

  • It returns exactly the same value as the internal _zoomLevel value as well as when the orientation or the angle is changed, which is in the MKMapViewโ€™s private API.
  • It preserves the value of heading and pitch of the camera property for a new zoom level as they are, rather than resetting the camera angle.
  • It returns the latest zoom level even when the animation of region change is not finished, in contrast with the camera property.

Usage

import MapKit
import MKZoomLevel

let mapView = MKMapView()

// Get the zoom level
mapView.zoomLevel

// Set the zoom level
mapView.zoomLevel = 16.0

// Set the zoom level with an animation
mapView.setZoomLevel(16.0, animated: true)

Installation

Swift Package Manager

Add this repository as a dependency in your Package.swift:

// swift-tools-version:5.0

import PackageDescription

let package = Package(
    ...,
    dependencies: [
        .package(url: "https://github.com/stleamist/MKZoomLevel.git", .upToNextMajor(from: "1.2.0"))
    ],
    ...
)

Xcode

Select File > Swift Packages > Add Package Dependency, then enter the following URL:

https://github.com/stleamist/MKZoomLevel.git

For more details, see Adding Package Dependencies to Your App.

License

MKZoomLevel is released under the MIT license. See LICENSE for details.

mkzoomlevel's People

Contributors

stleamist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.