Swiftpack.co -  xattacker/Polygon_iOS_API as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
xattacker/Polygon_iOS_API
an iOS swift Polygon UI View component
.package(url: "https://github.com/xattacker/Polygon_iOS_API.git", from: "1.0.2")

Polygon_iOS_API

an iOS swift Polygon UI View component

Development Target: iOS 9

Android version API: https://github.com/xattacker/Polygon_Android_API

present a custom defined polygon view:
screen cut

The API could load data from code for json file(json parsing by ObjectMapper https://github.com/Hearst-DD/ObjectMapper)
and supports event callback

Installation

Cocoapods

PolygonAPI can be added to your project using CocoaPods 0.36 or later by adding the following line to your Podfile:

pod 'ObjectMapper'
pod 'PolygonAPI'

Swift Package Manager

To add PolygonAPI to a Swift Package Manager based project, add:

.package(url: "https://github.com/xattacker/Polygon_iOS_API.git", .upToNextMajor(from: "1.0.2")),
.package(url: "https://github.com/tristanhimmelman/ObjectMapper.git", .upToNextMajor(from: "4.1.0")),

to your Package.swift files dependencies array.

How to use:

import PolygonAPI

var polygonView: UIPolygonView!

// load region map from json 
if let path = Bundle.main.path(forResource: "region", ofType: "json")
{
    do
    {
        // load map resource from json file
        let json = try String(contentsOfFile: path)

        if !json.isEmpty,
            let map = PolygonMap(JSONString: json)
        {
            self.polygonView.loadMap(map)
        }
    }
    catch
    {
    }
}


// you could also add map region by code:
let region = PolygonRegion()
region.regionColor = UIColor.brown
region.regionId = "north"
region.titleInfo.title = "北部"
region.addPoint(CGPoint(x: 167, y: 103))
region.addPoint(CGPoint(x: 194, y: 142))
region.addPoint(CGPoint(x: 251, y: 170))
region.addPoint(CGPoint(x: 306, y: 173))
region.addPoint(CGPoint(x: 322, y: 162))
region.addPoint(CGPoint(x: 314, y: 81))
region.addPoint(CGPoint(x: 338, y: 56))
region.addPoint(CGPoint(x: 330, y: 32))
region.addPoint(CGPoint(x: 291, y: 19))
region.addPoint(CGPoint(x: 269, y: 2))
region.addPoint(CGPoint(x: 254, y: 30))
region.addPoint(CGPoint(x: 192, y: 49))
self.polygonView.addRegion(region)


// the API provides delegate to catch some events
extension ViewController: UIPolygonViewDelegate
{
    func onRegionClicked(region: PolygonRegion)
    {
        // click region area event callback
    }
    
    func onRegionMarkClicked(mark: RegionMark, region: PolygonRegion)
    {
        // click mark event callback
    }
}

GitHub

link
Stars: 4
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

supported for SPM
37 weeks ago

update Package.swift

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API