Skip to content

Improved maps support #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion IntentKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.subspec 'Maps' do |ss|
ss.dependency 'IntentKit/Core'
ss.source_files = 'IntentKit/Handlers/INKMapsHandler.{h,m}'
ss.resource_bundles = { 'IntentKit-INKMapsHandler' => "IntentKit/Apps/{Maps,Google Maps,Waze}/*.{plist,png}" }
ss.resource_bundles = { 'IntentKit-INKMapsHandler' => "IntentKit/Apps/{Maps,Google Maps,Waze,CityMapper}/*.{plist,png}" }
ss.requires_arc = true
end

Expand Down
17 changes: 17 additions & 0 deletions IntentKit/Apps/CityMapper/CityMapper.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>CityMapper</string>
<key>actions</key>
<dict>
<key>directionsFrom:to:mode:</key>
<string>citymapper://directions?startcoord={{from}}&amp;endcoord={{to}}</string>
<key>searchForLocation:</key>
<string>citymapper://directions?endcoord={{center}}&amp;endname={{query}}</string>
<key>openLocation:title:</key>
<string>citymapper://directions?endcoord={{coordinate}}&amp;endname={{title}}</string>
</dict>
</dict>
</plist>
Binary file added IntentKit/Apps/CityMapper/CityMapper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IntentKit/Apps/CityMapper/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IntentKit/Apps/CityMapper/CityMapper@2x~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IntentKit/Apps/CityMapper/CityMapper~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions IntentKit/Apps/Google Maps/Google Maps.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<string>comgooglemaps://?saddr={{from}}&amp;daddr={{to}}&amp;directionsmode={{mode}}</string>
<key>searchForLocation:</key>
<string>comgooglemaps://?q={{query}}</string>
<key>openLocation:title:</key>
<string>comgooglemaps://?q={{coordinate}}</string>
</dict>
</dict>
</plist>
4 changes: 4 additions & 0 deletions IntentKit/Apps/Maps/Maps.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<string>Plans</string>
<key>nl</key>
<string>Kaarten</string>
<key>es</key>
<string>Mapas</string>
</dict>
<key>optional</key>
<dict>
Expand All @@ -26,6 +28,8 @@
<string>http://maps.apple.com/?saddr={{from}}&amp;daddr={{to}}</string>
<key>searchForLocation:</key>
<string>http://maps.apple.com/?q={{query}}</string>
<key>openLocation:title:</key>
<string>http://maps.apple.com/?q={{title}}&amp;ll={{coordinate}}</string>
</dict>
</dict>
</plist>
4 changes: 4 additions & 0 deletions IntentKit/Apps/Waze/Waze.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<dict>
<key>directionsFrom:to:mode:</key>
<string>waze://?ll={{to}}&amp;navigate=yes</string>
<key>openLocation:title:</key>
<string>waze://?ll={{coordinate}}</string>
<key>searchForLocation:</key>
<string>waze://?q={{query}}</string>
</dict>
</dict>
</plist>
10 changes: 9 additions & 1 deletion IntentKit/Handlers/INKMapsHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ typedef NS_ENUM(NSInteger, INKMapsHandlerDirectionsMode) {
@return A `INKActivityPresenter` object to present.

@warning This does not currently verify that an application can support multiple modes of transportation. If you pick an application that doesn't support the mode of transporation you've asked for, that application will likely ignore that part of the request. */

- (INKActivityPresenter *)directionsFrom:(NSString *)from to:(NSString *)to mode:(INKMapsHandlerDirectionsMode)mode;

/** Brings up turn-by-turn driving directions between two locations
Expand All @@ -60,4 +59,13 @@ typedef NS_ENUM(NSInteger, INKMapsHandlerDirectionsMode) {
@see directionsFrom:to:mode: */
- (INKActivityPresenter *)directionsFrom:(NSString *)from to:(NSString *)to;


/** Opens a specific point in a map

@param coordinate Coordinate to open
@param title String Name of the location. Note that some providers can not display name
@return A `INKActivityPresenter` object to present. */
- (INKActivityPresenter *)openLocation:(CLLocationCoordinate2D)coordinate title:(NSString *)title;


@end
11 changes: 11 additions & 0 deletions IntentKit/Handlers/INKMapsHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ - (INKActivityPresenter *)directionsFrom:(NSString *)from to:(NSString *)to {
return [self directionsFrom:from to:to mode:INKMapsHandlerDirectionsModeDriving];
}


- (INKActivityPresenter *)openLocation:(CLLocationCoordinate2D)coordinate title:(NSString *)title {
NSString *command = NSStringFromSelector(_cmd);
NSDictionary *args = [self argsDictionaryWithDictionary: @{
@"title": title,
@"coordinate": [NSString stringWithFormat:@"%f,%f", coordinate.latitude, coordinate.longitude]
}];

return [self performCommand:command withArguments:args];
}

#pragma mark - Private methods
- (NSDictionary *)argsDictionaryWithDictionary:(NSDictionary *)args {
NSMutableDictionary *newArgs = [args mutableCopy];
Expand Down