diff --git a/MTLocation.h b/MTLocation.h index cd69cf6..b865993 100644 --- a/MTLocation.h +++ b/MTLocation.h @@ -23,3 +23,4 @@ #import "MTLocationDefines.h" #import "MTLocationManager.h" #import "MTTouchesMovedGestureRecognizer.h" +#import "MTLocationFunctions.h" diff --git a/MTLocation.xcodeproj/project.pbxproj b/MTLocation.xcodeproj/project.pbxproj index b9e1042..e345051 100644 --- a/MTLocation.xcodeproj/project.pbxproj +++ b/MTLocation.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 392B1664132677BB00BF254A /* MTLocationFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 392B1662132677BB00BF254A /* MTLocationFunctions.h */; }; + 392B1665132677BB00BF254A /* MTLocationFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 392B1663132677BB00BF254A /* MTLocationFunctions.m */; }; 39382D7A12E9B6400012007D /* MTLocateMeBarButtonItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 39382D7512E9B6400012007D /* MTLocateMeBarButtonItem.h */; }; 39382D7B12E9B6400012007D /* MTLocateMeBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 39382D7612E9B6400012007D /* MTLocateMeBarButtonItem.m */; }; 39382D7C12E9B6400012007D /* MTLocateMeButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 39382D7712E9B6400012007D /* MTLocateMeButton.h */; }; @@ -27,6 +29,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 392B1662132677BB00BF254A /* MTLocationFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTLocationFunctions.h; sourceTree = ""; }; + 392B1663132677BB00BF254A /* MTLocationFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTLocationFunctions.m; sourceTree = ""; }; 39382D7512E9B6400012007D /* MTLocateMeBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTLocateMeBarButtonItem.h; sourceTree = ""; }; 39382D7612E9B6400012007D /* MTLocateMeBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTLocateMeBarButtonItem.m; sourceTree = ""; }; 39382D7712E9B6400012007D /* MTLocateMeButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTLocateMeButton.h; sourceTree = ""; }; @@ -165,6 +169,8 @@ 39382D7912E9B6400012007D /* MTLocationDefines.h */, 39645C0412FF585D008E8F9E /* MTTouchesMovedGestureRecognizer.h */, 39645C0512FF585D008E8F9E /* MTTouchesMovedGestureRecognizer.m */, + 392B1662132677BB00BF254A /* MTLocationFunctions.h */, + 392B1663132677BB00BF254A /* MTLocationFunctions.m */, ); name = Utils; sourceTree = ""; @@ -205,6 +211,7 @@ 39645C0612FF585D008E8F9E /* MTTouchesMovedGestureRecognizer.h in Headers */, 39B0E06A131E58950057991D /* MKMapView+MTLocation.h in Headers */, 39781DB31323C6A80030FB3D /* MKAnnotationView+MTLocation.h in Headers */, + 392B1664132677BB00BF254A /* MTLocationFunctions.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -264,6 +271,7 @@ 39645C0712FF585D008E8F9E /* MTTouchesMovedGestureRecognizer.m in Sources */, 39B0E06B131E58950057991D /* MKMapView+MTLocation.m in Sources */, 39781DB41323C6A80030FB3D /* MKAnnotationView+MTLocation.m in Sources */, + 392B1665132677BB00BF254A /* MTLocationFunctions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MTLocationFunctions.h b/MTLocationFunctions.h new file mode 100644 index 0000000..7e17f0b --- /dev/null +++ b/MTLocationFunctions.h @@ -0,0 +1,23 @@ +// +// MTLocationFunctions.h +// +// Created by Matthias Tretter on 8.3.2011. +// Copyright (c) 2009-2011 Matthias Tretter, @myell0w. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#import +#import + +#define kMTDirectionModeCar @"kMTDirectionModeCar" +#define kMTDirectionModeWalking @"w" +#define kMTDirectionModePublicTransport @"r" + + +void MTOpenDirectionInGoogleMaps(CLLocationCoordinate2D startingPoint, CLLocationCoordinate2D endPoint, NSString *directionMode); diff --git a/MTLocationFunctions.m b/MTLocationFunctions.m new file mode 100644 index 0000000..2486a4d --- /dev/null +++ b/MTLocationFunctions.m @@ -0,0 +1,29 @@ +// +// MTLocationFunctions.m +// +// Created by Matthias Tretter on 8.3.2011. +// Copyright (c) 2009-2011 Matthias Tretter, @myell0w. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +#import "MTLocationFunctions.h" + + + +void MTOpenDirectionInGoogleMaps(CLLocationCoordinate2D startingPoint, CLLocationCoordinate2D endPoint, NSString *directionMode) { + NSString *googleMapsURL = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", + startingPoint.latitude,startingPoint.longitude, endPoint.latitude, endPoint.longitude]; + + if (![directionMode isEqualToString:kMTDirectionModeCar]) { + googleMapsURL = [googleMapsURL stringByAppendingFormat:@"&dirflg=%@", directionMode]; + } + + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURL]]; +} diff --git a/MTTouchesMovedGestureRecognizer.m b/MTTouchesMovedGestureRecognizer.m index d75d9aa..a62486e 100644 --- a/MTTouchesMovedGestureRecognizer.m +++ b/MTTouchesMovedGestureRecognizer.m @@ -25,13 +25,25 @@ - (void)dealloc { [super dealloc]; } +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + NSLog(@"Began: %d", touches.count); +} + - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - NSLog(@"Touches: %d", touches.count); + NSLog(@"Moved: %d", touches.count); if (touches.count == 1 && self.touchesMovedCallback) { self.touchesMovedCallback(touches, event); } } +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + NSLog(@"Ended: %d", touches.count); +} + +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { + NSLog(@"Cancelled: %d", touches.count); +} + - (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer { return NO; }