Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Kml-Mapbox/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AppDelegate.swift
// Kml-Mapbox
//
// Created by Greg Pardo on 12/28/16.
// Copyright © 2016 asus4. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

68 changes: 68 additions & 0 deletions Kml-Mapbox/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
27 changes: 27 additions & 0 deletions Kml-Mapbox/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
58 changes: 58 additions & 0 deletions Kml-Mapbox/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1212" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="2Is-iX-AjI">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--KML Samples-->
<scene sceneID="nUg-GO-nOP">
<objects>
<tableViewController id="r2k-9l-hNA" userLabel="KML Samples" customClass="MainViewController" customModule="Kml_Mapbox" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="5eH-JB-dKZ">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Sample" id="Lnc-9W-321">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Lnc-9W-321" id="rsl-bT-2lc">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="r2k-9l-hNA" id="bX6-8l-Xzz"/>
<outlet property="delegate" destination="r2k-9l-hNA" id="B9S-BG-eoa"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="KML Samples" id="QFh-9Y-nJh"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="xM1-gx-eKD" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="263" y="-306"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="mtB-gN-645">
<objects>
<navigationController id="2Is-iX-AjI" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="MVz-GE-VUp">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="r2k-9l-hNA" kind="relationship" relationship="rootViewController" id="0rR-Gl-QfM"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="jVk-VQ-BPl" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-689" y="-306"/>
</scene>
</scenes>
</document>
52 changes: 52 additions & 0 deletions Kml-Mapbox/Examples/Path/PathViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// PathViewController.swift
// Kml
//
// Created by Koki Ibukuro on 8/18/15.
// Copyright (c) 2015 asus4. All rights reserved.
//

import UIKit
import Mapbox

// Path to MKPolylineRenderer
// Polygon to MKPolygonRenderer
class PathViewController: UIViewController {

@IBOutlet weak var mapView: MGLMapView!

override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
loadKml("sample")
}

fileprivate func loadKml(_ path: String) {
let url = Bundle.main.url(forResource: path, withExtension: "kml")
KMLDocument.parse(url!, callback:
{ [unowned self] (kml) in
self.mapView.add(kml.overlays)
self.mapView.addAnnotations(kml.annotations)
self.mapView.showAnnotations(kml.annotations, animated: true)
}
)
}
}

extension PathViewController: MGLMapViewDelegate {
func mapView(_ mapView: MGLMapView, alphaForShapeAnnotation annotation: MGLShape) -> CGFloat {
return annotation.alpha
}
func mapView(_ mapView: MGLMapView, strokeColorForShapeAnnotation annotation: MGLShape) -> UIColor {
return annotation.strokeColor ?? UIColor.black
}
func mapView(_ mapView: MGLMapView, fillColorForPolygonAnnotation annotation: MGLPolygon) -> UIColor {
return annotation.fillColor ?? UIColor.lightGray
}
func mapView(_ mapView: MGLMapView, lineWidthForPolylineAnnotation annotation: MGLPolyline) -> CGFloat {
return annotation.lineWidth
}
func mapView(_ mapView: MGLMapView, annotationCanShowCallout annotation: MGLAnnotation) -> Bool {
return true
}
}
37 changes: 37 additions & 0 deletions Kml-Mapbox/Examples/Path/PathViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1212" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11762"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="PathViewController" customModule="Kml_Mapbox" customModuleProvider="target">
<connections>
<outlet property="mapView" destination="ewZ-cZ-63u" id="rk2-0c-JKk"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ewZ-cZ-63u" customClass="MGLMapView">
<rect key="frame" x="-0.5" y="-0.5" width="375" height="667"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="ewZ-cZ-63u" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="29d-PK-2if"/>
<constraint firstItem="ewZ-cZ-63u" firstAttribute="height" secondItem="i5M-Pr-FkT" secondAttribute="height" id="lF1-Hj-mRA"/>
<constraint firstItem="ewZ-cZ-63u" firstAttribute="width" secondItem="i5M-Pr-FkT" secondAttribute="width" id="rec-MG-SBM"/>
<constraint firstItem="ewZ-cZ-63u" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="rtK-Un-jcd"/>
</constraints>
</view>
</objects>
</document>
38 changes: 38 additions & 0 deletions Kml-Mapbox/Examples/Placemark/PlacemarkViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// PlacemarkViewController.swift
// Kml
//
// Created by Koki Ibukuro on 8/17/15.
// Copyright (c) 2015 asus4. All rights reserved.
//

import UIKit
import Mapbox

// Placemark to MKAnnotation.
class PlacemarkViewController: UIViewController {

@IBOutlet weak var mapView: MGLMapView!

override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
loadKml("sample")
}

fileprivate func loadKml(_ path: String) {
let url = Bundle.main.url(forResource: path, withExtension: "kml")
KMLDocument.parse(url!, callback:
{ [unowned self] (kml) in
self.mapView.addAnnotations(kml.annotations)
self.mapView.showAnnotations(kml.annotations, animated: true)
}
)
}
}

extension PlacemarkViewController: MGLMapViewDelegate {
func mapView(_ mapView: MGLMapView, annotationCanShowCallout annotation: MGLAnnotation) -> Bool {
return true
}
}
37 changes: 37 additions & 0 deletions Kml-Mapbox/Examples/Placemark/PlacemarkViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1212" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11762"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="PlacemarkViewController" customModule="Kml_Mapbox" customModuleProvider="target">
<connections>
<outlet property="mapView" destination="Dvk-9c-mnt" id="eDO-dI-b6E"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dvk-9c-mnt" customClass="MGLMapView">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Dvk-9c-mnt" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="GIX-ne-6cs"/>
<constraint firstItem="Dvk-9c-mnt" firstAttribute="height" secondItem="i5M-Pr-FkT" secondAttribute="height" id="Jd0-Mp-Rzu"/>
<constraint firstItem="Dvk-9c-mnt" firstAttribute="width" secondItem="i5M-Pr-FkT" secondAttribute="width" id="h0K-yB-PUX"/>
<constraint firstItem="Dvk-9c-mnt" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="sJO-DD-ZXM"/>
</constraints>
</view>
</objects>
</document>
Loading