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
12 changes: 12 additions & 0 deletions MapWalker/MapWalker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
B2009BFD1D5BA1530016A625 /* JumpLocationWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2009BFC1D5BA1530016A625 /* JumpLocationWindowController.swift */; };
B2009BFF1D5BA1630016A625 /* JumpLocationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2009BFE1D5BA1630016A625 /* JumpLocationViewController.swift */; };
B2A9F13F1D5C69B5006C4B9C /* MapPin.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2A9F13E1D5C69B5006C4B9C /* MapPin.swift */; };
E182A4891D571E55002C9180 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E182A4881D571E55002C9180 /* AppDelegate.swift */; };
E182A48B1D571E55002C9180 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E182A48A1D571E55002C9180 /* ViewController.swift */; };
E182A48D1D571E55002C9180 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E182A48C1D571E55002C9180 /* Assets.xcassets */; };
Expand Down Expand Up @@ -37,6 +40,9 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
B2009BFC1D5BA1530016A625 /* JumpLocationWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JumpLocationWindowController.swift; sourceTree = "<group>"; };
B2009BFE1D5BA1630016A625 /* JumpLocationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JumpLocationViewController.swift; sourceTree = "<group>"; };
B2A9F13E1D5C69B5006C4B9C /* MapPin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapPin.swift; sourceTree = "<group>"; };
E182A4851D571E55002C9180 /* MapWalker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MapWalker.app; sourceTree = BUILT_PRODUCTS_DIR; };
E182A4881D571E55002C9180 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
E182A48A1D571E55002C9180 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -112,7 +118,10 @@
E182A4B81D57289B002C9180 /* WindowController.swift */,
E182A48C1D571E55002C9180 /* Assets.xcassets */,
E182A48E1D571E55002C9180 /* Main.storyboard */,
B2009BFC1D5BA1530016A625 /* JumpLocationWindowController.swift */,
B2009BFE1D5BA1630016A625 /* JumpLocationViewController.swift */,
E182A4911D571E55002C9180 /* Info.plist */,
B2A9F13E1D5C69B5006C4B9C /* MapPin.swift */,
);
path = MapWalker;
sourceTree = "<group>";
Expand Down Expand Up @@ -284,8 +293,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B2009BFF1D5BA1630016A625 /* JumpLocationViewController.swift in Sources */,
E182A48B1D571E55002C9180 /* ViewController.swift in Sources */,
B2A9F13F1D5C69B5006C4B9C /* MapPin.swift in Sources */,
E182A4B91D57289B002C9180 /* WindowController.swift in Sources */,
B2009BFD1D5BA1530016A625 /* JumpLocationWindowController.swift in Sources */,
E182A4891D571E55002C9180 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
48 changes: 46 additions & 2 deletions MapWalker/MapWalker/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
//

import Cocoa
import MapKit

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

class AppDelegate: NSObject, NSApplicationDelegate, JumpLocationProtocol {
func applicationDidFinishLaunching(notification: NSNotification) {
// Insert code here to initialize your application
}
Expand All @@ -19,5 +20,48 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// Insert code here to tear down your application
}

@IBAction func menuJumpToLocationClick(sender: AnyObject) {
let storyboard = NSStoryboard(name: "Main", bundle: nil)
let jumpLocationWindowController = storyboard.instantiateControllerWithIdentifier("JumpLocation") as! NSWindowController

if let jumpLocationWindow = jumpLocationWindowController.window {
let jumpLocationViewController = jumpLocationWindow.contentViewController as! JumpLocationViewController
jumpLocationViewController.delegate = self
if let coordinate = getCoordinateFromViewController() {
jumpLocationViewController.setCoordinate(coordinate)
let application = NSApplication.sharedApplication()
application.runModalForWindow(jumpLocationWindow)
}
}
}

@IBAction func menuRemoveAllPinsClick(sender: AnyObject) {
getMapViewController()?.handleRemoveAllPins()
}

func returnJumpToLocation(coordinate: CLLocationCoordinate2D) {
getMapViewController()?.handleJumpToLocation(coordinate)
}

func returnMarkItLocation(coordinate: CLLocationCoordinate2D) {
getMapViewController()?.handleMarkItLocation(coordinate)
}

func getuserLocation() -> CLLocationCoordinate2D? {
return getMapViewController()?.userLocationCoordinate;
}

func getMapViewController() -> ViewController? {
for window in NSApplication.sharedApplication().windows {
if let viewController:ViewController = window.contentViewController as? ViewController {
return viewController
}
}
return nil
}

func getCoordinateFromViewController() -> CLLocationCoordinate2D? {
return getMapViewController()?.centerCoordinate;
}
}

Loading