Commit 1eb1e80a authored by Deployer's avatar Deployer

Initial Import of Cedarmaps iOS SDK

parents
# references:
# * http://www.objc.io/issue-6/travis-ci.html
# * https://github.com/supermarin/xcpretty#usage
language: objective-c
# cache: cocoapods
# podfile: Example/Podfile
# before_install:
# - gem install cocoapods # Since Travis is not always on latest version
# - pod install --project-directory=Example
install:
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
script:
- set -o pipefail && xcodebuild test -workspace Example/CedarMap.xcworkspace -scheme CedarMap-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty -c
- pod lib lint --quick
#
# Be sure to run `pod lib lint CedarMap.podspec' to ensure this is a
# valid spec and remove all comments before submitting the spec.
#
# Any lines starting with a # are optional, but encouraged
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = "CedarMap"
s.version = "0.1.0"
s.summary = "Cedar Studio iOS SDK"
s.description = "Cedar Studio should write something to introduce their Pod."
s.homepage = "http://cedar.ir"
s.license = 'MIT'
s.author = { "Emad A." => "emad310@gmail.com" }
s.source = { :git => "http://gitlab.cedar.ir/cedar.studios/cedarmaps-sdk-ios.git", :tag => s.version.to_s }
s.platform = :ios, '7.0'
s.requires_arc = true
s.source_files = 'Pod/Classes'
s.resource_bundles = {
'CedarMap' => ['Pod/Assets/*.png']
}
s.public_header_files = 'Pod/Classes/**/*.h'
s.frameworks = 'UIKit'
s.dependency 'Mapbox-iOS-SDK', '~> 1.5.0'
end
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:CedarMap.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6003F589195388D20070C39A"
BuildableName = "CedarMap.app"
BlueprintName = "CedarMap"
ReferencedContainer = "container:CedarMap.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6003F5AD195388D20070C39A"
BuildableName = "Tests.xctest"
BlueprintName = "Tests"
ReferencedContainer = "container:CedarMap.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6003F589195388D20070C39A"
BuildableName = "CedarMap.app"
BlueprintName = "CedarMap"
ReferencedContainer = "container:CedarMap.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6003F589195388D20070C39A"
BuildableName = "CedarMap.app"
BlueprintName = "CedarMap"
ReferencedContainer = "container:CedarMap.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6003F589195388D20070C39A"
BuildableName = "CedarMap.app"
BlueprintName = "CedarMap"
ReferencedContainer = "container:CedarMap.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:CedarMap.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="t4v-zE-Ran">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<scenes>
<!--Search View Controller-->
<scene sceneID="5u7-PP-lhT">
<objects>
<viewController id="hj0-IR-2tU" customClass="CSSearchViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Cjd-Ln-aej">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" id="AQD-fj-JIR" customClass="RMMapView">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" id="0p1-7U-4GH">
<rect key="frame" x="6" y="20" width="308" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" adjustsFontSizeToFit="NO" minimumFontSize="17" id="rge-xy-m38">
<rect key="frame" x="35" y="0.0" width="263" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits" returnKeyType="search"/>
<connections>
<outlet property="delegate" destination="hj0-IR-2tU" id="AtT-iM-imk"/>
</connections>
</textField>
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" id="xEt-cm-S4d">
<rect key="frame" x="8" y="10" width="20" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</activityIndicatorView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" red="0.91372549020000005" green="0.91372549020000005" blue="0.91372549020000005" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<outlet property="delegate" destination="hj0-IR-2tU" id="tug-86-dpa"/>
</connections>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<tabBarItem key="tabBarItem" systemItem="search" id="h6k-GT-8cr"/>
<connections>
<outlet property="mapView" destination="AQD-fj-JIR" id="OsI-ff-nM9"/>
<outlet property="searchTextField" destination="rge-xy-m38" id="TfD-dk-GZj"/>
<outlet property="searchView" destination="0p1-7U-4GH" id="3XS-Hf-bm4"/>
<outlet property="spinner" destination="xEt-cm-S4d" id="LRi-76-GcP"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="eQC-Gc-mW4" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="225" y="650"/>
</scene>
<!--Bookmarks View Controller-->
<scene sceneID="LCL-zf-6AE">
<objects>
<viewController id="zHL-Jq-Uo2" customClass="CSBookmarksViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="drh-RE-z0M">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" id="jSh-jc-HHQ" customClass="RMMapView">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="delegate" destination="zHL-Jq-Uo2" id="bk3-ul-kd4"/>
</connections>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<tabBarItem key="tabBarItem" systemItem="bookmarks" id="A5z-PF-sHq"/>
<connections>
<outlet property="mapView" destination="jSh-jc-HHQ" id="jjz-el-5vY"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ls9-Eb-oMA" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="225" y="20"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="iWJ-rQ-kga">
<objects>
<tabBarController id="t4v-zE-Ran" sceneMemberID="viewController">
<nil key="simulatedBottomBarMetrics"/>
<tabBar key="tabBar" contentMode="scaleToFill" id="SRk-UR-lmT">
<rect key="frame" x="0.0" y="0.0" width="320" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tabBar>
<connections>
<segue destination="zHL-Jq-Uo2" kind="relationship" relationship="viewControllers" id="5EU-sq-997"/>
<segue destination="hj0-IR-2tU" kind="relationship" relationship="viewControllers" id="j9a-ED-wYc"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="22n-iy-wxt" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-315" y="335"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
//
// CSAppDelegate.h
// CedarMap
//
// Created by CocoaPods on 01/19/2015.
// Copyright (c) 2014 Emad A.. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CSAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
//
// CSAppDelegate.m
// CedarMap
//
// Created by CocoaPods on 01/19/2015.
// Copyright (c) 2014 Emad A.. All rights reserved.
//
#import "CSAppDelegate.h"
@implementation CSAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// 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 throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// 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.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// 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.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
//
// CSBookmarksViewController.h
// CedarMap
//
// Created by Emad A. on 01/19/2015.
// Copyright (c) 2014 Emad A.. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CedarMap.h"
@interface CSBookmarksViewController : UIViewController
@property (nonatomic, strong) IBOutlet RMMapView *mapView;
@end
//
// CSBookmarksViewController.m
// CedarMap
//
// Created by Emad A. on 01/19/2015.
// Copyright (c) 2014 Emad A.. All rights reserved.
//
#import "CSBookmarksViewController.h"
#pragma mark - CSViewController Private Interface
#pragma maek
@interface CSBookmarksViewController () <RMMapViewDelegate>
@end
#pragma mark - CSViewController Implementation
#pragma maek
@implementation CSBookmarksViewController
- (void)viewDidLoad
{
[super viewDidLoad];
CSAuthenticationManager *auth = [CSAuthenticationManager sharedManager];
[auth setCredentialsWithClientId:@"user"
clientSecret:@"pass"];
CSMapSource *source = [[CSMapSource alloc] initWithMapId:@"cedarmaps.streets"];
self.mapView.tileSource = source;
self.mapView.hideAttribution = YES;
self.mapView.showLogoBug = NO;
self.mapView.zoom = 16;
[self.mapView removeAllCachedImages];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
/*
[self markBusStation];
[self markTrainStation];
[self markPointNumberOne];
[self markPointNumberTwo];
[self markPointNumberThree];
*/
self.mapView.centerCoordinate = CLLocationCoordinate2DMake(35.770889877650724, 51.439468860626214);
}
#pragma mark -
#pragma mark - RMMapViewDelegate Methods
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation) {
return nil;
}
RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:annotation.userInfo]];
marker.anchorPoint = CGPointMake(1, 1);
marker.canShowCallout = YES;
return marker;
}
#pragma mark -
- (void)markBusStation
{
RMAnnotation *annotation = [RMAnnotation annotationWithMapView:self.mapView
coordinate:CLLocationCoordinate2DMake(35.770889877650724, 51.439468860626214)
andTitle:@"ایستگاه اتوبوس"];
annotation.userInfo = @"bus_station";
[self.mapView addAnnotation:annotation];
}
- (void)markTrainStation
{
RMAnnotation *annotation = [RMAnnotation annotationWithMapView:self.mapView
coordinate:CLLocationCoordinate2DMake(35.772857173873305, 51.437859535217285)
andTitle:@"مترو"];
annotation.userInfo = @"train_station";
[self.mapView addAnnotation:annotation];
}
- (void)markPointNumberOne
{
RMAnnotation *annotation = [RMAnnotation annotationWithMapView:self.mapView
coordinate:CLLocationCoordinate2DMake(35.77633899479261, 51.4344048500061)
andTitle:@"نقطه اول"];
annotation.userInfo = @"point_one";
[self.mapView addAnnotation:annotation];
}
- (void)markPointNumberTwo
{
RMAnnotation *annotation = [RMAnnotation annotationWithMapView:self.mapView
coordinate:CLLocationCoordinate2DMake(35.77943768718256, 51.437666416168206)
andTitle:@"نقطه دوم"];
annotation.userInfo = @"point_two";
[self.mapView addAnnotation:annotation];
}
- (void)markPointNumberThree
{
RMAnnotation *annotation = [RMAnnotation annotationWithMapView:self.mapView
coordinate:CLLocationCoordinate2DMake(35.77773168047123, 51.44279479980469)
andTitle:@"نقطه سوم"];
annotation.userInfo = @"point_three";
[self.mapView addAnnotation:annotation];
}
@end
//
// CSSearchViewController.h
// CedarMap
//
// Created by Emad A. on 6/02/2015.
// Copyright (c) 2015 Emad A. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CedarMap.h"
@interface CSSearchViewController : UIViewController <UITextFieldDelegate>
@property (nonatomic, weak) IBOutlet RMMapView *mapView;
@property (nonatomic, weak) IBOutlet UIView *searchView;
@property (nonatomic, weak) IBOutlet UIView *searchTextField;
@property (nonatomic, weak) IBOutlet UIActivityIndicatorView *spinner;
@end
//
// CSSearchViewController.m
// CedarMap
//
// Created by Emad A. on 6/02/2015.
// Copyright (c) 2015 Emad A. All rights reserved.
//
#import "CSSearchViewController.h"
#pragma mark - CSSearchViewController Private Interface
#pragma mark
@interface CSSearchViewController () <RMMapViewDelegate>
@property (nonatomic, strong) CSMapSource *mapSource;
@end
#pragma mark - CSSearchViewController Implementation
#pragma mark
@implementation CSSearchViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Customizing search view and textfield
self.searchView.layer.shadowOffset = CGSizeMake(0, 1);
self.searchView.layer.shadowOpacity = .3;
self.searchView.layer.shadowRadius = 1.5;
self.searchView.layer.cornerRadius = 2;
self.searchView.alpha = .95;
// Initializing map source
self.mapSource = [[CSMapSource alloc] initWithMapId:@"cedarmaps.streets"];
// Setting map view properties
self.mapView.tileSource = self.mapSource;
self.mapView.hideAttribution = YES;
self.mapView.showLogoBug = NO;
self.mapView.zoom = 16;
//[self.mapView removeAllCachedImages];
self.mapView.centerCoordinate = CLLocationCoordinate2DMake(35.757552763570196, 51.41000747680664);
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (self.mapView.annotations.count == 0) {
[self.searchTextField becomeFirstResponder];
}
}
#pragma mark - UITextFieldDelegate Methods
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self.spinner startAnimating];
[textField resignFirstResponder];
[self searchWithQueryString:textField.text];
return NO;
}
#pragma mark - RMMapViewDelegate Methods
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation) {
return nil;
}
RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"star"]];
marker.anchorPoint = CGPointMake(1, 1);
marker.canShowCallout = YES;
return marker;
}
#pragma mark - Private Methods
- (void)searchWithQueryString:(NSString *)query
{
CSQueryParameters *params = [CSQueryParameters new];
[params addLocationWithLatitude:self.mapView.centerCoordinate.latitude longitude:self.mapView.centerCoordinate.longitude];
[self.mapSource forwardGeocodingWithQueryString:query parameters:params completion:^(NSArray *results, NSError *error) {
[self.spinner stopAnimating];
if (error != nil) {
[[[UIAlertView alloc] initWithTitle:@"بروز خطا"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"باشه"
otherButtonTitles:nil] show];
return;
}
[self.mapView removeAllAnnotations];
for (NSDictionary *item in results) {
NSArray *center = [[item objectForKey:@"location"][@"center"] componentsSeparatedByString:@","];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([center[0] doubleValue], [center[1] doubleValue]);
RMAnnotation *annotation = [RMAnnotation annotationWithMapView:self.mapView
coordinate:coordinate
andTitle:[item objectForKey:@"name"]];
annotation.userInfo = @"search_result";
[self.mapView addAnnotation:annotation];
}
if (results.count > 0) {
RMAnnotation *firstAnnotation = [self.mapView.annotations objectAtIndex:0];
[self.mapView setCenterCoordinate:firstAnnotation.coordinate animated:YES];
}
else {
[[[UIAlertView alloc] initWithTitle:@"جستجو بدون نتیجه"
message:@"مکان مورد نظر پیدا نشد."
delegate:nil
cancelButtonTitle:@"باشه"
otherButtonTitles:nil] show];
}
}];
}
@end
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>Main_iPhone</string>
<key>UIMainStoryboardFile~ipad</key>
<string>Main_iPad</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "App Icon 120x120.png",
"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"
}
}
\ No newline at end of file
{
"images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "Portrait---6-Plus.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"orientation" : "landscape",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "8.0",
"subtype" : "736h",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "Portrait---6.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "Portrait---4.png",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "Portrait---5.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"subtype" : "retina4",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "to-status-bar",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "to-status-bar",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "to-status-bar",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "to-status-bar",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "bus-stop.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "bus-stop@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "1.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "1@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "3.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "3@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "2.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "2@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "star.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "star@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "metro.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "metro@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
/* Localized versions of Info.plist keys */
//
// main.m
// CedarMap
//
// Created by Emad A. on 01/19/2015.
// Copyright (c) 2014 Emad A.. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CSAppDelegate.h"
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([CSAppDelegate class]));
}
}
source 'https://github.com/CocoaPods/Specs.git'
target 'CedarMap', :exclusive => true do
pod "CedarMap", :path => "../"
end
target 'Tests', :exclusive => true do
pod "CedarMap", :path => "../"
end
PODS:
- CedarMap (0.0.11):
- Mapbox-iOS-SDK (~> 1.5.0)
- FMDB (2.3):
- FMDB/standard (= 2.3)
- FMDB/common (2.3)
- FMDB/standard (2.3):
- FMDB/common
- GRMustache (6.8.3):
- JRSwizzle (~> 1.0)
- JRSwizzle (1.0)
- Mapbox-iOS-SDK (1.5.1):
- FMDB (= 2.3)
- GRMustache (= 6.8.3)
- SMCalloutView (= 2.0)
- SMCalloutView (2.0)
DEPENDENCIES:
- CedarMap (from `../`)
EXTERNAL SOURCES:
CedarMap:
:path: ../
SPEC CHECKSUMS:
CedarMap: f3a1285da2187a31dba1463207fea9386663680b
FMDB: 31ec26773c7f7b7890a6038235a1f2bbd933a7cb
GRMustache: ab96109b7ba4b9568425bea40d6cd2cdc7582b6c
JRSwizzle: 30da7a2c539a4ebf954b16d15f6dd8221c9f6fa5
Mapbox-iOS-SDK: 78612041d438b10be1e4ba1a21e39a24bc874ab0
SMCalloutView: c1906604d47c058400ade5c9d52ab98aa77b7e76
COCOAPODS: 0.35.0
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every test case source file.
//
#ifdef __OBJC__
#endif
//
// CedarMapTests.m
// CedarMapTests
//
// Created by Emad A. on 01/19/2015.
// Copyright (c) 2014 Emad A.. All rights reserved.
//
${TEST_EXAMPLE}
/* Localized versions of Info.plist keys */
Copyright (c) 2015 Emad A. <emad310@gmail.com>
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.
//
// CSAuthenticationManager.h
// Pods
//
// Created by Emad A. on 3/02/2015.
//
//
#import <Foundation/Foundation.h>
@interface CSAuthenticationManager : NSObject
@property (nonatomic, copy, readonly) NSString *clientId;
@property (nonatomic, copy, readonly) NSString *clientSecret;
@property (nonatomic, copy, readonly) NSString *accessToken;
- (void)setCredentialsWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret;
- (void)requestAccessToken:(NSError *__autoreleasing *)error;
- (void)invalidateCredential;
+ (CSAuthenticationManager *)sharedManager;
@end
//
// CSAuthenticationManager.m
// Pods
//
// Created by Emad A. on 3/02/2015.
//
//
#import "CSAuthenticationManager.h"
static NSString * const kBaseURL = @"http://api.cedarmaps.com/v1";
static NSString * const kCurrentAccessToken = @"CedarMapsSDKUserAccessToken_v1";
@interface CSAuthenticationManager () {
NSString *_accessToken;
}
@end
@implementation CSAuthenticationManager
- (NSString *)accessToken
{
if (_accessToken == nil) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
_accessToken = [defaults objectForKey:kCurrentAccessToken];
if (_accessToken == nil) {
[self requestAccessToken:nil];
}
}
return _accessToken;
}
- (void)setCredentialsWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret
{
NSAssert(clientId != nil && clientId.length > 0, @"Given Client ID is not in acceptable format.");
NSAssert(clientSecret != nil && clientSecret.length > 0, @"Given Client Secret is not in acceptable format.");
_clientId = clientId;
_clientSecret = clientSecret;
}
- (void)requestAccessToken:(NSError *__autoreleasing *)error
{
NSAssert(self.clientId != nil, @"No client id specified. Set your given credentials before trying to get an access token.");
NSAssert(self.clientSecret != nil, @"No client Secret specified. Set your given credentials before trying to get an access token.");
NSString *params = [NSString stringWithFormat:@"client_id=%@&client_secret=%@", self.clientId, self.clientSecret];
params = [params stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *tokenURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/token", kBaseURL]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:tokenURL];
[request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPMethod:@"POST"];
NSError *responseError = nil;
NSHTTPURLResponse *response = nil;
NSData *token = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&responseError];
if (response.statusCode == 200) {
NSError *serializationError = nil;
NSDictionary *result = [NSJSONSerialization JSONObjectWithData:token options:0 error:&serializationError];
if (serializationError != nil && error != nil) {
*error = serializationError;
return;
}
_accessToken = result[@"access_token"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:_accessToken forKey:kCurrentAccessToken];
[defaults synchronize];
}
else if (responseError != nil && error != nil) {
*error = responseError;
}
}
- (void)invalidateCredential
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:kCurrentAccessToken];
[defaults synchronize];
_accessToken = nil;
}
#pragma mark - Singleton Methods
static CSAuthenticationManager *sharedInstance;
+ (void)initialize
{
static BOOL initialized = NO;
if (initialized == NO) {
initialized = YES;
sharedInstance = [[CSAuthenticationManager alloc] init];
}
}
+ (CSAuthenticationManager *)sharedManager
{
return sharedInstance;
}
@end
//
// CSMapSource.h
// Pods
//
// Created by Emad A. on 30/01/2015.
//
//
#import "Mapbox.h"
@class CSQueryParameters;
/* An CSMapSource is used to display map tiles from a network-based map hosted on Cedar Map.
* Map should be referenced by their map ID.
*/
@interface CSMapSource : RMAbstractWebMapSource
@property (nonatomic, copy, readonly) NSString *mapId;
@property (nonatomic, readonly) NSString *version;
@property (nonatomic, readonly) RMSphericalTrapezium bounds;
- (id)initWithMapId:(NSString *)mapId;
- (id)initWithMapId:(NSString *)mapId enablingDataOnMapView:(RMMapView *)mapView;
- (void)forwardGeocodingWithQueryString:(NSString *)query
parameters:(CSQueryParameters *)parameters
completion:(void (^)(NSArray *results, NSError *error))completion;
- (void)reverseGeocodingWithCoordinate:(CLLocationCoordinate2D)coordinate
completion:(void (^)(NSDictionary *result, NSError *error))completion;
@end
#pragma mark
@interface CSQueryParameters : NSObject
- (void)addCity:(NSString *)city;
- (void)addLimit:(NSUInteger)limit;
- (void)addDistance:(CGFloat)distance;
- (void)addLocationWithLatitude:(CGFloat)latitude longitude:(CGFloat)longitude;
@end
#define CSMapSourceErrorNotification @"CSMapSourceErrorNotification"
\ No newline at end of file
This diff is collapsed.
//
// CedarMap.h
// Pods
//
// Created by Emad A. on 19/01/2015.
//
//
#import "Mapbox.h"
#import "CSMapSource.h"
#import "CSAuthenticationManager.h"
# CedarMap
## Usage
To run the example project, clone the repo, and run `pod install` from the Example directory first.
To use CedarStudio Map you need a pair of client ID and secret which is needed at the first step of initialising the SDK.
CSAuthenticationManager *auth = [CSAuthenticationManager sharedManager];
[auth setCredentialsWithClientId:@“<your client Id>“ clientSecret:@“<your client secret>”];
Then an instance of CSMapSource should be initialised:
CSMapSource *source = [[CSMapSource alloc] initWithMapId:@"cedarmaps.streets"];
``MapId`` actually is the style of will be shown by source and could be anything but at the moment the only accepted value is ``cedarmaps.streets``. We will add other values and style latter.
The map source instance will be used as tile source for a ``RMMapView``:
self.mapView.tileSource = source;
or initialised a ``CSMapSource`` with your instance of ``RMMapView``:
CSMapSource *source = [[CSMapSource alloc] initWithMapId:@"cedarmaps.streets" enablingDataOnMapView:self.mapView];
``CSMapSource`` has two methods for forward geocoding and reverse geocoding that returne a ``NSArray`` and ``NSDictionary`` respectively as soon as their job get done.
- (void)forwardGeocodingWithQueryString:(NSString *)query parameters:(CSQueryParameters *)parameters completion:(void (^)(NSArray *results, NSError *error))completion;
- (void)reverseGeocodingWithCoordinate:(CLLocationCoordinate2D)coordinate completion:(void (^)(NSDictionary *result, NSError *error))completion;
In case you have got a credential error with ``nil`` as the result, there might be something wrong with your credentials at server side. So, before retrying and sending the request again request a new access token by calling method ``- (void)requestAccessToken:(NSError *__autoreleasing *)error`` of ``CSAuthenticationManager`` class.
## Requirements
- Mapbox-iOS-SDK
## Installation
CedarMap is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
pod "CedarMap"
## Author
## License
CedarMap is available under the MIT license. See the LICENSE file for more info.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment