Commit 442e1d7b authored by Deployer's avatar Deployer

Updated mapbox to version 3.3. Added Swift example

parent 1d154e86
......@@ -8,24 +8,19 @@
#
Pod::Spec.new do |s|
s.name = "CedarMaps"
s.version = "0.1.6"
s.summary = "Cedar Studio iOS SDK"
s.description = "Cedar Studio should write something to introduce their Pod."
s.homepage = "http://cedar.ir"
s.name = 'CedarMaps'
s.version = '1.0.0'
s.cocoapods_version = '>= 0.36'
s.license = 'MIT'
s.author = { "Emad A." => "emad310@gmail.com" }
s.source = { :git => "http://gitlab.cedar.ir/cedar.studios/cedarmaps-sdk-ios-public.git", :tag => s.version.to_s }
s.platform = :ios, '7.1'
s.requires_arc = true
s.homepage = 'https://www.kikojas.com/about-cedarmaps'
s.authors = { 'Emad A.' => 'emad310@gmail.com', 'Saeed T' => 'saeed.taheri@gmail.com' }
s.summary = 'CedarMaps iOS SDK'
s.source = { :git => 'http://gitlab.cedar.ir/cedar.studios/cedarmaps-sdk-ios-public.git', :tag => s.version.to_s }
s.source_files = 'Pod/Classes'
s.resource_bundles = {
'CedarMap' => ['Pod/Assets/*.png']
}
s.framework = 'UIKit'
s.platform = :ios, '8.0'
s.requires_arc = true
s.resource_bundles = { 'CedarMap' => ['Pod/Assets/*.png' ] }
s.public_header_files = 'Pod/Classes/**/*.h'
s.frameworks = 'UIKit'
s.dependency 'Mapbox-iOS-SDK', '1.6.0'
s.dependency 'Mapbox-iOS-SDK', '~> 3.3.4'
end
\ No newline at end of file
source 'https://github.com/CocoaPods/Specs.git'
target 'CedarMaps' do
pod 'CedarMaps', :git => 'http://gitlab.cedar.ir/cedar.studios/cedarmaps-sdk-ios-public.git'
end
target 'Tests' do
pod 'CedarMaps', :git => 'http://gitlab.cedar.ir/cedar.studios/cedarmaps-sdk-ios-public.git'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = 'NO'
end
end
end
\ No newline at end of file
PODS:
- CedarMaps (0.1.5):
- 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:
- CedarMaps (from `http://gitlab.cedar.ir/cedar.studios/cedarmaps-sdk-ios-public.git`)
EXTERNAL SOURCES:
CedarMaps:
:git: http://gitlab.cedar.ir/cedar.studios/cedarmaps-sdk-ios-public.git
CHECKOUT OPTIONS:
CedarMaps:
:commit: 6f85015ad7a9219a7049d1dc96d73a45eb1db608
:git: http://gitlab.cedar.ir/cedar.studios/cedarmaps-sdk-ios-public.git
SPEC CHECKSUMS:
CedarMaps: cdb5e7b32a3a48cafa2bbb6f1b14c8cf181e8b35
FMDB: e78c5941bb10563f2b707255119e3655e790c29e
GRMustache: 3840864eb8c23b07bbdbcbc469f11bb1210d6f13
JRSwizzle: dd5ead5d913a0f29e7f558200165849f006bb1e3
Mapbox-iOS-SDK: c8f6353fb999a6b6fb22856a6d26ba36c3c87fd1
SMCalloutView: f758edd824b18bf4f42de00df1e299861a2d1950
PODFILE CHECKSUM: 5645086d63b7607a7b89b38c279867437e2d5bdd
COCOAPODS: 1.0.0.beta.3
//
// 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 */
......@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
0408C2DD1A986EE400047FA6 /* CedarMaps.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 0408C2DC1A986EE400047FA6 /* CedarMaps.podspec */; };
04A1C2511A848CB40002A695 /* CSSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A1C2501A848CB40002A695 /* CSSearchViewController.m */; };
0B51B8C85BB120B979E8D38C /* libPods-Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1632EC4E2FAF87C99320B8DC /* libPods-Tests.a */; };
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; };
6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
......@@ -19,29 +18,12 @@
6003F5A1195388D20070C39A /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6003F59F195388D20070C39A /* Main_iPhone.storyboard */; };
6003F5A7195388D20070C39A /* CSBookmarksViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5A6195388D20070C39A /* CSBookmarksViewController.m */; };
6003F5A9195388D20070C39A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5A8195388D20070C39A /* Images.xcassets */; };
6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F5AF195388D20070C39A /* XCTest.framework */; };
6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; };
7CD0DE5121AD9557FBA27CE0 /* libPods-CedarMaps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D7EA748FF4F8D26F379D5033 /* libPods-CedarMaps.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
6003F5B3195388D20070C39A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6003F582195388D10070C39A /* Project object */;
proxyType = 1;
remoteGlobalIDString = 6003F589195388D20070C39A;
remoteInfo = CedarMap;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0408C2DC1A986EE400047FA6 /* CedarMaps.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CedarMaps.podspec; path = ../CedarMaps.podspec; sourceTree = "<group>"; };
04A1C24F1A848CB40002A695 /* CSSearchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSearchViewController.h; sourceTree = "<group>"; };
04A1C2501A848CB40002A695 /* CSSearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSearchViewController.m; sourceTree = "<group>"; };
1632EC4E2FAF87C99320B8DC /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
59D7ECBFE0E151D98648C54E /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
6003F58A195388D20070C39A /* CedarMaps.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CedarMaps.app; sourceTree = BUILT_PRODUCTS_DIR; };
6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
......@@ -57,18 +39,8 @@
6003F5A5195388D20070C39A /* CSBookmarksViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSBookmarksViewController.h; sourceTree = "<group>"; };
6003F5A6195388D20070C39A /* CSBookmarksViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CSBookmarksViewController.m; sourceTree = "<group>"; };
6003F5A8195388D20070C39A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
6003F5AE195388D20070C39A /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6003F5AF195388D20070C39A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
6003F5B7195388D20070C39A /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = "<group>"; };
6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = "<group>"; };
606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = "<group>"; };
68BB8F34DF3E628F5E094960 /* Pods-CedarMaps.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CedarMaps.release.xcconfig"; path = "Pods/Target Support Files/Pods-CedarMaps/Pods-CedarMaps.release.xcconfig"; sourceTree = "<group>"; };
7C7B45AE7C9F5232A7AD89FD /* Pods-Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.debug.xcconfig"; sourceTree = "<group>"; };
B2D3F3785CF2E622C9814346 /* Pods-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.release.xcconfig"; sourceTree = "<group>"; };
C2FB25A5E6D8483FB5A6EEBF /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
D7EA748FF4F8D26F379D5033 /* libPods-CedarMaps.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CedarMaps.a"; sourceTree = BUILT_PRODUCTS_DIR; };
F1B569AFADC1FB19792043E7 /* Pods-CedarMaps.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CedarMaps.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CedarMaps/Pods-CedarMaps.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -79,44 +51,19 @@
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */,
6003F592195388D20070C39A /* UIKit.framework in Frameworks */,
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */,
7CD0DE5121AD9557FBA27CE0 /* libPods-CedarMaps.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
6003F5AB195388D20070C39A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */,
6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */,
6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */,
0B51B8C85BB120B979E8D38C /* libPods-Tests.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
077782CE8C5431F7B0F4EB14 /* Pods */ = {
isa = PBXGroup;
children = (
F1B569AFADC1FB19792043E7 /* Pods-CedarMaps.debug.xcconfig */,
68BB8F34DF3E628F5E094960 /* Pods-CedarMaps.release.xcconfig */,
7C7B45AE7C9F5232A7AD89FD /* Pods-Tests.debug.xcconfig */,
B2D3F3785CF2E622C9814346 /* Pods-Tests.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
6003F581195388D10070C39A = {
isa = PBXGroup;
children = (
60FF7A9C1954A5C5007DD14C /* Podspec Metadata */,
6003F593195388D20070C39A /* CedarMaps */,
6003F5B5195388D20070C39A /* Tests */,
6003F58C195388D20070C39A /* Frameworks */,
6003F58B195388D20070C39A /* Products */,
077782CE8C5431F7B0F4EB14 /* Pods */,
);
sourceTree = "<group>";
};
......@@ -124,7 +71,6 @@
isa = PBXGroup;
children = (
6003F58A195388D20070C39A /* CedarMaps.app */,
6003F5AE195388D20070C39A /* Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
......@@ -136,8 +82,6 @@
6003F58F195388D20070C39A /* CoreGraphics.framework */,
6003F591195388D20070C39A /* UIKit.framework */,
6003F5AF195388D20070C39A /* XCTest.framework */,
D7EA748FF4F8D26F379D5033 /* libPods-CedarMaps.a */,
1632EC4E2FAF87C99320B8DC /* libPods-Tests.a */,
);
name = Frameworks;
sourceTree = "<group>";
......@@ -169,25 +113,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
6003F5B5195388D20070C39A /* Tests */ = {
isa = PBXGroup;
children = (
6003F5BB195388D20070C39A /* Tests.m */,
6003F5B6195388D20070C39A /* Supporting Files */,
);
path = Tests;
sourceTree = "<group>";
};
6003F5B6195388D20070C39A /* Supporting Files */ = {
isa = PBXGroup;
children = (
6003F5B7195388D20070C39A /* Tests-Info.plist */,
6003F5B8195388D20070C39A /* InfoPlist.strings */,
606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
60FF7A9C1954A5C5007DD14C /* Podspec Metadata */ = {
isa = PBXGroup;
children = (
......@@ -205,12 +130,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "CedarMaps" */;
buildPhases = (
BB1AAD18D17BBA66D52719CD /* Check Pods Manifest.lock */,
6003F586195388D20070C39A /* Sources */,
6003F587195388D20070C39A /* Frameworks */,
6003F588195388D20070C39A /* Resources */,
264FE16616F6331C781DAFE5 /* Embed Pods Frameworks */,
9E6EB656E2F29D7356F12096 /* Copy Pods Resources */,
);
buildRules = (
);
......@@ -221,27 +143,6 @@
productReference = 6003F58A195388D20070C39A /* CedarMaps.app */;
productType = "com.apple.product-type.application";
};
6003F5AD195388D20070C39A /* Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "Tests" */;
buildPhases = (
4AEA6DFF3DE9F453E8812B6C /* Check Pods Manifest.lock */,
6003F5AA195388D20070C39A /* Sources */,
6003F5AB195388D20070C39A /* Frameworks */,
6003F5AC195388D20070C39A /* Resources */,
F998501612D19CAD5FC6256D /* Embed Pods Frameworks */,
12059087B2FE0456945DC35C /* Copy Pods Resources */,
);
buildRules = (
);
dependencies = (
6003F5B4195388D20070C39A /* PBXTargetDependency */,
);
name = Tests;
productName = CedarMapTests;
productReference = 6003F5AE195388D20070C39A /* Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
......@@ -249,11 +150,11 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = CS;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Emad A.";
TargetAttributes = {
6003F5AD195388D20070C39A = {
TestTargetID = 6003F589195388D20070C39A;
6003F589195388D20070C39A = {
ProvisioningStyle = Automatic;
};
};
};
......@@ -271,7 +172,6 @@
projectRoot = "";
targets = (
6003F589195388D20070C39A /* CedarMaps */,
6003F5AD195388D20070C39A /* Tests */,
);
};
/* End PBXProject section */
......@@ -288,109 +188,8 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
6003F5AC195388D20070C39A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
12059087B2FE0456945DC35C /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
264FE16616F6331C781DAFE5 /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CedarMaps/Pods-CedarMaps-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
4AEA6DFF3DE9F453E8812B6C /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
9E6EB656E2F29D7356F12096 /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CedarMaps/Pods-CedarMaps-resources.sh\"\n";
showEnvVarsInLog = 0;
};
BB1AAD18D17BBA66D52719CD /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
F998501612D19CAD5FC6256D /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
6003F586195388D20070C39A /* Sources */ = {
isa = PBXSourcesBuildPhase;
......@@ -403,24 +202,8 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
6003F5AA195388D20070C39A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6003F5BC195388D20070C39A /* Tests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
6003F5B4195388D20070C39A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 6003F589195388D20070C39A /* CedarMaps */;
targetProxy = 6003F5B3195388D20070C39A /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
6003F596195388D20070C39A /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
......@@ -438,14 +221,6 @@
name = Main_iPhone.storyboard;
sourceTree = "<group>";
};
6003F5B8195388D20070C39A /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
6003F5B9195388D20070C39A /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
......@@ -462,14 +237,19 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
......@@ -482,7 +262,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
......@@ -502,20 +282,25 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
......@@ -524,15 +309,15 @@
};
6003F5C0195388D20070C39A /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F1B569AFADC1FB19792043E7 /* Pods-CedarMaps.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer: Emad A. (8YN74ESJTN)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CedarMaps/CedarMaps-Prefix.pch";
INFOPLIST_FILE = "CedarMaps/CedarMaps-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_BUNDLE_IDENTIFIER = com.cedarmaps.example.ObjC;
PRODUCT_NAME = CedarMaps;
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
......@@ -541,65 +326,21 @@
};
6003F5C1195388D20070C39A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 68BB8F34DF3E628F5E094960 /* Pods-CedarMaps.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer: Emad A. (8YN74ESJTN)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CedarMaps/CedarMaps-Prefix.pch";
INFOPLIST_FILE = "CedarMaps/CedarMaps-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_BUNDLE_IDENTIFIER = com.cedarmaps.example.ObjC;
PRODUCT_NAME = CedarMaps;
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
};
name = Release;
};
6003F5C3195388D20070C39A /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7C7B45AE7C9F5232A7AD89FD /* Pods-Tests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CedarMap.app/CedarMap";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = "Tests/Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
};
name = Debug;
};
6003F5C4195388D20070C39A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B2D3F3785CF2E622C9814346 /* Pods-Tests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CedarMap.app/CedarMap";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch";
INFOPLIST_FILE = "Tests/Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
......@@ -621,15 +362,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
6003F5C3195388D20070C39A /* Debug */,
6003F5C4195388D20070C39A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 6003F582195388D10070C39A /* Project object */;
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......
<?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">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES" initialViewController="t4v-zE-Ran">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Search View Controller-->
<!--Delegate-->
<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"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<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"/>
<view contentMode="scaleToFill" id="AQD-fj-JIR" customClass="MGLMapView">
<frame key="frameInset"/>
<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"/>
<frame key="frameInset" minX="6" minY="3.67%" height="40" maxX="6"/>
<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"/>
<frame key="frameInset" minX="35" maxX="10"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits" returnKeyType="search"/>
<connections>
......@@ -32,30 +33,41 @@
</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"/>
<frame key="frameInset" minX="8" minY="10" width="20" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</activityIndicatorView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
<color key="backgroundColor" red="0.91372549020000005" green="0.91372549020000005" blue="0.91372549020000005" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.91372549020000005" green="0.91372549020000005" blue="0.91372549020000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="zoomLevel">
<real key="value" value="14"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="latitude">
<real key="value" value="35.757552763570196"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="longitude">
<real key="value" value="51.410007476806641"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="delegate" destination="hj0-IR-2tU" id="tug-86-dpa"/>
</connections>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="bV6-3P-wiJ">
<rect key="frame" x="0.0" y="490" width="100" height="25"/>
<frame key="frameInset" width="100" height="25" maxY="53"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<state key="normal" image="attribution">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="attributionDidTouchUpInside:" destination="hj0-IR-2tU" eventType="touchUpInside" id="R1V-1t-l6a"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<tabBarItem key="tabBarItem" systemItem="search" id="h6k-GT-8cr"/>
<connections>
......@@ -67,38 +79,49 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="eQC-Gc-mW4" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="225" y="650"/>
<point key="canvasLocation" x="225" y="726"/>
</scene>
<!--Bookmarks View Controller-->
<!--Delegate-->
<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"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<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"/>
<view contentMode="scaleToFill" id="jSh-jc-HHQ" customClass="MGLMapView">
<frame key="frameInset"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="G88-Us-ELx">
<rect key="frame" x="0.0" y="490" width="100" height="25"/>
<frame key="frameInset" width="100" height="25" maxY="53"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<state key="normal" image="attribution">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="attributionDidTouchUpInside:" destination="zHL-Jq-Uo2" eventType="touchUpInside" id="UJy-H4-e8g"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="zoomLevel">
<real key="value" value="14"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="latitude">
<real key="value" value="35.770889877650724"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="longitude">
<real key="value" value="51.439468860626214"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="delegate" destination="zHL-Jq-Uo2" id="bk3-ul-kd4"/>
</connections>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<tabBarItem key="tabBarItem" systemItem="bookmarks" id="A5z-PF-sHq"/>
<connections>
......@@ -107,7 +130,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ls9-Eb-oMA" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="225" y="20"/>
<point key="canvasLocation" x="225" y="-154"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="iWJ-rQ-kga">
......@@ -117,7 +140,7 @@
<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"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</tabBar>
<connections>
<segue destination="zHL-Jq-Uo2" kind="relationship" relationship="viewControllers" id="5EU-sq-997"/>
......@@ -130,11 +153,11 @@
</scene>
</scenes>
<resources>
<image name="attribution" width="82" height="32"/>
<image name="attribution" width="73" height="23"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
</simulatedMetricsContainer>
</document>
......@@ -11,6 +11,6 @@
@interface CSBookmarksViewController : UIViewController
@property (nonatomic, strong) IBOutlet RMMapView *mapView;
@property (nonatomic, weak) IBOutlet MGLMapView *mapView;
@end
......@@ -9,9 +9,8 @@
#import "CSBookmarksViewController.h"
#pragma mark - CSViewController Private Interface
#pragma maek
@interface CSBookmarksViewController () <RMMapViewDelegate>
@interface CSBookmarksViewController () <MGLMapViewDelegate>
@end
......@@ -25,32 +24,32 @@
[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;
[auth setCredentialsWithClientID:@"clientID"
clientSecret:@"clientSecret"];
[self.mapView removeAllCachedImages];
CSMapKit *mapKit = [[CSMapKit alloc] initWithMapID:@"cedarmaps.streets"];
[mapKit styleURLWithCompletion:^(NSURL *url) {
dispatch_async(dispatch_get_main_queue(), ^{
self.mapView.styleURL = url;
});
}];
self.mapView.attributionButton.alpha = 0;
self.mapView.logoView.alpha = 0;
}
- (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
......@@ -60,65 +59,62 @@
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://cedarmaps.com"]];
}
#pragma mark - RMMapViewDelegate Methods
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation) {
return nil;
}
#pragma mark - MGLMapViewDelegate Methods
RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:annotation.userInfo]];
marker.anchorPoint = CGPointMake(1, 1);
marker.canShowCallout = YES;
- (MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id<MGLAnnotation>)annotation {
MGLAnnotationImage *image = [MGLAnnotationImage annotationImageWithImage:[UIImage imageNamed:annotation.subtitle] reuseIdentifier:annotation.subtitle];
return image;
}
return marker;
- (BOOL)mapView:(MGLMapView *)mapView annotationCanShowCallout:(id<MGLAnnotation>)annotation {
return YES;
}
#pragma mark -
- (void)markBusStation
{
RMAnnotation *annotation = [RMAnnotation annotationWithMapView:self.mapView
coordinate:CLLocationCoordinate2DMake(35.770889877650724, 51.439468860626214)
andTitle:@"ایستگاه اتوبوس"];
annotation.userInfo = @"bus_station";
MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(35.770889877650724, 51.439468860626214);
annotation.title = @"ایستگاه اتوبوس";
annotation.subtitle = @"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";
MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(35.772857173873305, 51.437859535217285);
annotation.title = @"مترو";
annotation.subtitle = @"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";
MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(35.77633899479261, 51.4344048500061);
annotation.title = @"نقطه اول";
annotation.subtitle = @"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";
MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(35.77943768718256, 51.437666416168206);
annotation.title = @"نقطه دوم";
annotation.subtitle = @"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";
MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(35.77773168047123, 51.44279479980469);
annotation.title = @"نقطه سوم";
annotation.subtitle = @"point_three";
[self.mapView addAnnotation:annotation];
}
......
......@@ -11,7 +11,7 @@
@interface CSSearchViewController : UIViewController <UITextFieldDelegate>
@property (nonatomic, weak) IBOutlet RMMapView *mapView;
@property (nonatomic, weak) IBOutlet MGLMapView *mapView;
@property (nonatomic, weak) IBOutlet UIView *searchView;
@property (nonatomic, weak) IBOutlet UIView *searchTextField;
@property (nonatomic, weak) IBOutlet UIActivityIndicatorView *spinner;
......
......@@ -11,9 +11,9 @@
#pragma mark - CSSearchViewController Private Interface
#pragma mark
@interface CSSearchViewController () <RMMapViewDelegate>
@interface CSSearchViewController () <MGLMapViewDelegate>
@property (nonatomic, strong) CSMapSource *mapSource;
@property (nonatomic, strong) CSMapKit *mapKit;
@end
......@@ -34,17 +34,17 @@
self.searchView.alpha = .95;
// Initializing map source
self.mapSource = [[CSMapSource alloc] initWithMapId:@"cedarmaps.streets"];
self.mapKit = [[CSMapKit 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.mapKit styleURLWithCompletion:^(NSURL *url) {
dispatch_async(dispatch_get_main_queue(), ^{
self.mapView.styleURL = url;
});
}];
self.mapView.attributionButton.alpha = 0;
self.mapView.logoView.alpha = 0;
self.mapView.centerCoordinate = CLLocationCoordinate2DMake(35.757552763570196, 51.41000747680664);
}
- (void)viewDidAppear:(BOOL)animated
......@@ -75,62 +75,65 @@
return NO;
}
#pragma mark - RMMapViewDelegate Methods
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation) {
return nil;
}
#pragma mark - MGLMapViewDelegate Methods
RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"star"]];
marker.anchorPoint = CGPointMake(1, 1);
marker.canShowCallout = YES;
- (MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id<MGLAnnotation>)annotation {
MGLAnnotationImage *image = [MGLAnnotationImage annotationImageWithImage:[UIImage imageNamed:@"star"] reuseIdentifier:@"marker"];
return image;
}
return marker;
- (BOOL)mapView:(MGLMapView *)mapView annotationCanShowCallout:(id<MGLAnnotation>)annotation {
return YES;
}
#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];
}
CSQueryParameters *params = [[CSQueryParameters alloc] init];
[params addLocationWithCoordinate:self.mapView.centerCoordinate];
[params addDistance:10.0];
[self.mapKit forwardGeocodingWithQueryString:query parameters:params completion:^(NSArray *results, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.spinner stopAnimating];
if (error != nil) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"بروز خطا" message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"باشه" style:UIAlertActionStyleCancel handler:NULL]];
[self presentViewController:alert animated:YES completion:NULL];
return;
}
if (self.mapView.annotations && self.mapView.annotations.count > 0) {
[self.mapView removeAnnotations:self.mapView.annotations];
}
for (NSDictionary *item in results) {
NSArray *center = [[item objectForKey:@"location"][@"center"] componentsSeparatedByString:@","];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([center[0] doubleValue], [center[1] doubleValue]);
MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
annotation.coordinate = coordinate;
annotation.title = [item objectForKey:@"name"];
[self.mapView addAnnotation:annotation];
}
if (results.count > 0) {
MGLPointAnnotation *firstAnnotation = self.mapView.annotations.firstObject;
[self.mapView setCenterCoordinate:firstAnnotation.coordinate animated:YES];
}
else {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"جستجو بدون نتیجه" message:@"مکان مورد نظر پیدا نشد." preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"باشه" style:UIAlertActionStyleCancel handler:NULL]];
[self presentViewController:alert animated:YES completion:NULL];
}
});
}];
}
......
......@@ -29,6 +29,8 @@
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Maps Needs Location</string>
<key>UIMainStoryboardFile</key>
<string>Main_iPhone</string>
<key>UIMainStoryboardFile~ipad</key>
......
......@@ -2,6 +2,16 @@
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
......@@ -33,6 +43,16 @@
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
......
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'CedarMaps' do
pod 'CedarMaps'
end
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
303579981DBF78330012DB20 /* CSAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 303579971DBF78330012DB20 /* CSAppDelegate.swift */; };
3035799A1DBF78330012DB20 /* CSBookmarksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 303579991DBF78330012DB20 /* CSBookmarksViewController.swift */; };
3035799F1DBF78330012DB20 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3035799E1DBF78330012DB20 /* Assets.xcassets */; };
303579A21DBF78330012DB20 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 303579A01DBF78330012DB20 /* LaunchScreen.storyboard */; };
303579AB1DBF78BC0012DB20 /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 303579AA1DBF78BC0012DB20 /* Main_iPhone.storyboard */; };
30D94E2F1DBF7B2500FAE1AE /* CSSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30D94E2E1DBF7B2500FAE1AE /* CSSearchViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
303579941DBF78330012DB20 /* Example_Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example_Swift.app; sourceTree = BUILT_PRODUCTS_DIR; };
303579971DBF78330012DB20 /* CSAppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CSAppDelegate.swift; sourceTree = "<group>"; };
303579991DBF78330012DB20 /* CSBookmarksViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CSBookmarksViewController.swift; sourceTree = "<group>"; };
3035799E1DBF78330012DB20 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
303579A11DBF78330012DB20 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
303579A31DBF78330012DB20 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
303579AA1DBF78BC0012DB20 /* Main_iPhone.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main_iPhone.storyboard; sourceTree = "<group>"; };
30D94E2E1DBF7B2500FAE1AE /* CSSearchViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSSearchViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
303579911DBF78330012DB20 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
3035798B1DBF78330012DB20 = {
isa = PBXGroup;
children = (
303579961DBF78330012DB20 /* CedarMaps */,
303579951DBF78330012DB20 /* Products */,
);
sourceTree = "<group>";
};
303579951DBF78330012DB20 /* Products */ = {
isa = PBXGroup;
children = (
303579941DBF78330012DB20 /* Example_Swift.app */,
);
name = Products;
sourceTree = "<group>";
};
303579961DBF78330012DB20 /* CedarMaps */ = {
isa = PBXGroup;
children = (
303579971DBF78330012DB20 /* CSAppDelegate.swift */,
303579991DBF78330012DB20 /* CSBookmarksViewController.swift */,
30D94E2E1DBF7B2500FAE1AE /* CSSearchViewController.swift */,
303579AA1DBF78BC0012DB20 /* Main_iPhone.storyboard */,
303579A91DBF789F0012DB20 /* Supporting Files */,
);
name = CedarMaps;
path = Example_Swift;
sourceTree = "<group>";
};
303579A91DBF789F0012DB20 /* Supporting Files */ = {
isa = PBXGroup;
children = (
3035799E1DBF78330012DB20 /* Assets.xcassets */,
303579A01DBF78330012DB20 /* LaunchScreen.storyboard */,
303579A31DBF78330012DB20 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
303579931DBF78330012DB20 /* Example_Swift */ = {
isa = PBXNativeTarget;
buildConfigurationList = 303579A61DBF78330012DB20 /* Build configuration list for PBXNativeTarget "Example_Swift" */;
buildPhases = (
303579901DBF78330012DB20 /* Sources */,
303579911DBF78330012DB20 /* Frameworks */,
303579921DBF78330012DB20 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Example_Swift;
productName = Example_Swift;
productReference = 303579941DBF78330012DB20 /* Example_Swift.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
3035798C1DBF78330012DB20 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Cedar Studios";
TargetAttributes = {
303579931DBF78330012DB20 = {
CreatedOnToolsVersion = 8.0;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 3035798F1DBF78330012DB20 /* Build configuration list for PBXProject "Example_Swift" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 3035798B1DBF78330012DB20;
productRefGroup = 303579951DBF78330012DB20 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
303579931DBF78330012DB20 /* Example_Swift */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
303579921DBF78330012DB20 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
303579A21DBF78330012DB20 /* LaunchScreen.storyboard in Resources */,
3035799F1DBF78330012DB20 /* Assets.xcassets in Resources */,
303579AB1DBF78BC0012DB20 /* Main_iPhone.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
303579901DBF78330012DB20 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3035799A1DBF78330012DB20 /* CSBookmarksViewController.swift in Sources */,
30D94E2F1DBF7B2500FAE1AE /* CSSearchViewController.swift in Sources */,
303579981DBF78330012DB20 /* CSAppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
303579A01DBF78330012DB20 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
303579A11DBF78330012DB20 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
303579A41DBF78330012DB20 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
303579A51DBF78330012DB20 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
303579A71DBF78330012DB20 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Example_Swift/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.cedarmaps.Example-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
303579A81DBF78330012DB20 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Example_Swift/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.cedarmaps.Example-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
3035798F1DBF78330012DB20 /* Build configuration list for PBXProject "Example_Swift" */ = {
isa = XCConfigurationList;
buildConfigurations = (
303579A41DBF78330012DB20 /* Debug */,
303579A51DBF78330012DB20 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
303579A61DBF78330012DB20 /* Build configuration list for PBXNativeTarget "Example_Swift" */ = {
isa = XCConfigurationList;
buildConfigurations = (
303579A71DBF78330012DB20 /* Debug */,
303579A81DBF78330012DB20 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 3035798C1DBF78330012DB20 /* Project object */;
}
......@@ -2,9 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "group:CedarMaps.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
location = "self:Example_Swift.xcodeproj">
</FileRef>
</Workspace>
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "App Icon 120x120.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"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"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"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" : "cedarmaps-attribution.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cedarmaps-attribution@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"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
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<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" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</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>
//
// AppDelegate.swift
// Example_Swift
//
// Created by Saeed Taheri on 2016/10/25.
// Copyright © 2016 Cedar Studios. All rights reserved.
//
import UIKit
@UIApplicationMain
class CSAppDelegate: 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:.
}
}
//
// ViewController.swift
// Example_Swift
//
// Created by Saeed Taheri on 2016/10/25.
// Copyright © 2016 Cedar Studios. All rights reserved.
//
import UIKit
import CedarMaps
class CSBookmarksViewController: UIViewController {
@IBOutlet weak var mapView: MGLMapView!
override func viewDidLoad() {
super.viewDidLoad()
let auth = CSAuthenticationManager.shared()
auth?.setCredentialsWithClientID("clientID", clientSecret: "clientSecret")
let mapKit = CSMapKit(mapID: "cedarmaps.streets")
mapKit?.styleURL(completion: { (url) in
DispatchQueue.main.async {
self.mapView.styleURL = url
}
})
mapView.attributionButton.alpha = 0
mapView.logoView.alpha = 0
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
markBusStation()
markTrainStation()
markPointNumberOne()
markPointNumberTwo()
markPointNumberThree()
}
@IBAction func attributionDidTouchUpInside(_ sender: UIButton?) {
UIApplication.shared.openURL(URL(string: "http://cedarmaps.com")!)
}
}
extension CSBookmarksViewController: MGLMapViewDelegate {
func mapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? {
let image = MGLAnnotationImage(image: UIImage(named: annotation.subtitle!!)!, reuseIdentifier: annotation.subtitle!!)
return image
}
func mapView(_ mapView: MGLMapView, annotationCanShowCallout annotation: MGLAnnotation) -> Bool {
return true
}
fileprivate func markBusStation() {
let annotation = MGLPointAnnotation()
annotation.coordinate = CLLocationCoordinate2DMake(35.770889877650724, 51.439468860626214)
annotation.title = "ایستگاه اتوبوس"
annotation.subtitle = "bus_station"
mapView.addAnnotation(annotation)
}
fileprivate func markTrainStation() {
let annotation = MGLPointAnnotation()
annotation.coordinate = CLLocationCoordinate2DMake(35.772857173873305, 51.437859535217285)
annotation.title = "مترو"
annotation.subtitle = "train_station"
mapView.addAnnotation(annotation)
}
fileprivate func markPointNumberOne() {
let annotation = MGLPointAnnotation()
annotation.coordinate = CLLocationCoordinate2DMake(35.77633899479261, 51.4344048500061)
annotation.title = "نقطه اول"
annotation.subtitle = "point_one"
mapView.addAnnotation(annotation)
}
fileprivate func markPointNumberTwo() {
let annotation = MGLPointAnnotation()
annotation.coordinate = CLLocationCoordinate2DMake(35.77943768718256, 51.437666416168206)
annotation.title = "نقطه دوم"
annotation.subtitle = "point_two"
mapView.addAnnotation(annotation)
}
fileprivate func markPointNumberThree() {
let annotation = MGLPointAnnotation()
annotation.coordinate = CLLocationCoordinate2DMake(35.77773168047123, 51.44279479980469)
annotation.title = "نقطه سوم"
annotation.subtitle = "point_three"
mapView.addAnnotation(annotation)
}
}
//
// CSSearchViewController.swift
// Example_Swift
//
// Created by Saeed Taheri on 2016/10/25.
// Copyright © 2016 Cedar Studios. All rights reserved.
//
import UIKit
import CedarMaps
class CSSearchViewController: UIViewController {
@IBOutlet weak var mapView: MGLMapView!
@IBOutlet weak var searchView: UIView!
@IBOutlet weak var searchTextField: UIView!
@IBOutlet weak var spinner: UIActivityIndicatorView!
fileprivate var mapKit = CSMapKit(mapID: "cedarmaps.streets")
override func viewDidLoad() {
super.viewDidLoad()
// Customizing search view and textfield
searchView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
searchView.layer.shadowOpacity = 0.3
searchView.layer.shadowRadius = 1.5
searchView.layer.cornerRadius = 2
searchView.alpha = 0.95
mapKit?.styleURL(completion: { (url) in
DispatchQueue.main.async {
self.mapView.styleURL = url
}
})
mapView.attributionButton.alpha = 0
mapView.logoView.alpha = 0
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if mapView.annotations?.count == 0 {
searchTextField.becomeFirstResponder()
}
}
@IBAction func attributionDidTouchUpInside(_ sender: UIButton?) {
UIApplication.shared.openURL(URL(string: "http://cedarmaps.com")!)
}
fileprivate func search(with query: String?) {
guard let query = query else { return }
let params = CSQueryParameters()
params.addLocation(with: mapView.centerCoordinate)
params.addDistance(10.0)
mapKit?.forwardGeocoding(withQueryString: query, parameters: params, completion: { (results, error) in
DispatchQueue.main.async {
self.spinner.stopAnimating()
if error != nil {
let alert = UIAlertController(title: "بروز خطا", message: error?.localizedDescription ?? " ", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "باشه", style: .cancel, handler: nil))
self.present(alert, animated: true, completion: nil)
return
}
if let annotations = self.mapView.annotations, annotations.count > 0 {
self.mapView.removeAnnotations(annotations)
}
for item in results! where item is NSDictionary {
let itemDic = item as! NSDictionary
if let center = ((itemDic.object(forKey: "location") as? NSDictionary)?.object(forKey: "center") as? String)?.components(separatedBy: ","), center.count == 2 {
let coordinate = CLLocationCoordinate2DMake(Double(center[0])!, Double(center[1])!)
let annotation = MGLPointAnnotation()
annotation.coordinate = coordinate
annotation.title = itemDic.object(forKey: "name") as? String
self.mapView.addAnnotation(annotation)
}
}
if results!.count > 0 {
if let firstAnnotation = self.mapView.annotations?.first {
self.mapView.setCenter(firstAnnotation.coordinate, animated: true)
}
} else {
let alert = UIAlertController(title: "جستجو بدون نتیجه", message: "مکان مورد نظر پیدا نشد.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "باشه", style: .cancel, handler: nil))
self.present(alert, animated: true, completion: nil)
return
}
}
})
}
}
extension CSSearchViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
spinner.startAnimating()
textField.resignFirstResponder()
search(with: textField.text)
return false
}
}
extension CSSearchViewController: MGLMapViewDelegate {
func mapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? {
let image = MGLAnnotationImage(image: UIImage(named: "star")!, reuseIdentifier: "marker")
return image
}
func mapView(_ mapView: MGLMapView, annotationCanShowCallout annotation: MGLAnnotation) -> Bool {
return true
}
}
......@@ -5,18 +5,41 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main_iPhone</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Maps Needs Location</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES" initialViewController="t4v-zE-Ran">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Delegate-->
<scene sceneID="5u7-PP-lhT">
<objects>
<viewController id="hj0-IR-2tU" customClass="CSSearchViewController" customModule="Example_Swift" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Cjd-Ln-aej">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" id="AQD-fj-JIR" customClass="MGLMapView">
<frame key="frameInset"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" id="0p1-7U-4GH">
<frame key="frameInset" minX="6" minY="3.67%" height="40" maxX="6"/>
<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">
<frame key="frameInset" minX="35" maxX="10"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<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">
<frame key="frameInset" minX="8" minY="10" width="20" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</activityIndicatorView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
<color key="backgroundColor" red="0.91372549020000005" green="0.91372549020000005" blue="0.91372549020000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="zoomLevel">
<real key="value" value="14"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="latitude">
<real key="value" value="35.757552763570196"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="longitude">
<real key="value" value="51.410007476806641"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="delegate" destination="hj0-IR-2tU" id="tug-86-dpa"/>
</connections>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="bV6-3P-wiJ">
<frame key="frameInset" width="100" height="25" maxY="53"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<state key="normal" image="attribution">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="attributionDidTouchUpInside:" destination="hj0-IR-2tU" eventType="touchUpInside" id="R1V-1t-l6a"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</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="726"/>
</scene>
<!--Delegate-->
<scene sceneID="LCL-zf-6AE">
<objects>
<viewController id="zHL-Jq-Uo2" customClass="CSBookmarksViewController" customModule="Example_Swift" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="drh-RE-z0M">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" id="jSh-jc-HHQ" customClass="MGLMapView">
<frame key="frameInset"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="G88-Us-ELx">
<frame key="frameInset" width="100" height="25" maxY="53"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<state key="normal" image="attribution">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="attributionDidTouchUpInside:" destination="zHL-Jq-Uo2" eventType="touchUpInside" id="UJy-H4-e8g"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="zoomLevel">
<real key="value" value="14"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="latitude">
<real key="value" value="35.770889877650724"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="longitude">
<real key="value" value="51.439468860626214"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="delegate" destination="zHL-Jq-Uo2" id="bk3-ul-kd4"/>
</connections>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</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="-154"/>
</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" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</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>
<resources>
<image name="attribution" width="73" height="23"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
</simulatedMetricsContainer>
</document>
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target Example_Swift do
pod 'CedarMaps'
end
......@@ -10,16 +10,16 @@
@interface CSAuthenticationManager : NSObject
@property (nonatomic, copy, readonly) NSString *clientId;
@property (nonatomic, copy, readonly) NSString *clientID;
@property (nonatomic, copy, readonly) NSString *clientSecret;
@property (nonatomic, copy, readonly) NSString *accessToken;
@property (nonatomic, copy) NSString *baseURL;
- (void)setCredentialsWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret;
- (void)requestAccessToken:(NSError *__autoreleasing *)error;
- (void)invalidateCredential;
+ (CSAuthenticationManager *)sharedManager;
- (void)setCredentialsWithClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret;
- (void)requestAccessTokenFromServer:(void (^)(NSString *token, NSError *error))completion;
- (void)savedAccessToken:(void (^) (NSString *token))completion;
- (void)invalidateCredential;
@end
......@@ -11,9 +11,9 @@
static NSString * const kBaseURL = @"http://api.cedarmaps.com/v1";
static NSString * const kCurrentAccessToken = @"CedarMapsSDKUserAccessToken_v1";
@interface CSAuthenticationManager () {
NSString *_accessToken;
}
@interface CSAuthenticationManager ()
@property (nonatomic, strong) NSString *accessToken;
@end
......@@ -29,35 +29,37 @@ static NSString * const kCurrentAccessToken = @"CedarMapsSDKUserAccessToken_v1";
return self;
}
- (NSString *)accessToken
{
if (_accessToken == nil) {
- (void)savedAccessToken:(void (^) (NSString *token))completion {
if (!_accessToken) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
_accessToken = [defaults objectForKey:kCurrentAccessToken];
if (_accessToken == nil) {
[self requestAccessToken:nil];
if (!_accessToken) {
[self requestAccessTokenFromServer:^(NSString *token, NSError *error) {
completion(token);
}];
} else {
completion(_accessToken);
}
} else {
completion(_accessToken);
}
return _accessToken;
}
- (void)setCredentialsWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret
- (void)setCredentialsWithClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret
{
NSAssert(clientId != nil && clientId.length > 0, @"Given Client ID is not in acceptable format.");
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;
_clientID = clientID;
_clientSecret = clientSecret;
}
- (void)requestAccessToken:(NSError *__autoreleasing *)error
- (void)requestAccessTokenFromServer:(void (^)(NSString *token, NSError *error))completion
{
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.");
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];
NSString *params = [NSString stringWithFormat:@"client_id=%@&client_secret=%@", self.clientID, self.clientSecret];
params = [params stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *tokenURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/token", self.baseURL]];
......@@ -65,27 +67,34 @@ static NSString * const kCurrentAccessToken = @"CedarMapsSDKUserAccessToken_v1";
[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;
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable token, NSURLResponse * _Nullable response, NSError * _Nullable responseError) {
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
if (statusCode == 200) {
NSError *serializationError;
NSDictionary *result = [NSJSONSerialization JSONObjectWithData:token options:0 error:&serializationError];
if (serializationError != nil) {
completion(nil, serializationError);
return;
}
_accessToken = result[@"access_token"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:_accessToken forKey:kCurrentAccessToken];
completion(_accessToken, nil);
return;
} else if (responseError != nil) {
completion(nil, responseError);
return;
}
} else if (responseError != nil) {
completion(nil, responseError);
return;
}
_accessToken = result[@"access_token"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:_accessToken forKey:kCurrentAccessToken];
[defaults synchronize];
}
else if (responseError != nil && error != nil) {
*error = responseError;
}
}] resume];
}
- (void)invalidateCredential
......
//
// CSMapSource.h
// CSMapStyle.h
// Pods
//
// Created by Emad A. on 30/01/2015.
//
//
#import "Mapbox.h"
@import CoreLocation;
@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.
/* A CSMapKit is used to display map tiles from a network-based map hosted on CedarMaps as well as getting geocoding data from server.
* Maps should be referenced by their map ID.
*/
@interface CSMapSource : RMAbstractWebMapSource
@interface CSMapKit: NSObject
@property (nonatomic, copy, readonly) NSString *mapId;
@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;
- (instancetype)initWithMapID:(NSString *)mapID;
- (void)styleURLWithCompletion:(void (^) (NSURL *url))completion;
- (void)forwardGeocodingWithQueryString:(NSString *)query
parameters:(CSQueryParameters *)parameters
completion:(void (^)(NSArray *results, NSError *error))completion;
......@@ -37,9 +34,7 @@
- (void)addCity:(NSString *)city;
- (void)addLimit:(NSUInteger)limit;
- (void)addDistance:(CGFloat)distance;
- (void)addLocationWithLatitude:(CGFloat)latitude longitude:(CGFloat)longitude;
- (void)addDistance:(CLLocationDistance)distance;
- (void)addLocationWithCoordinate:(CLLocationCoordinate2D)coordinate;
@end
#define CSMapSourceErrorNotification @"CSMapSourceErrorNotification"
\ No newline at end of file
//
// CSMapStyle.m
// Pods
//
// Created by Emad A. on 30/01/2015.
//
//
#import "CSMapKit.h"
#import "CSAuthenticationManager.h"
#define HTTP_404_NOT_FOUND 404
#define HTTP_401_NOT_AUTHORIZED 401
#define TOKEN_NOT_PROVIDED @"Token is not provided"
#define TOKEN_NOT_PROVIDED_CODE -68
#define INVALID_CREDINTIAL @"Invalid credential"
#pragma mark - CSQueryParameters Private Interface
@interface CSQueryParameters ()
@property (nonatomic, strong) NSMutableDictionary *params;
@end
#pragma mark - CSMapSource Private Interface
@interface CSMapKit ()
@property (nonatomic, copy) NSString *mapID;
@end
#pragma mark - CSMapSource Implementation
@implementation CSMapKit
- (instancetype)initWithMapID:(NSString *)mapID
{
self = [super init];
if (self != nil) {
self.mapID = mapID;
}
return self;
}
#pragma mark StyleURL
- (void)styleURLWithCompletion:(void (^) (NSURL *url))completion {
[[CSAuthenticationManager sharedManager] savedAccessToken:^(NSString *token) {
NSString *tileJSONURLString = [NSString stringWithFormat:@"%@/styles/%@.json", [[CSAuthenticationManager sharedManager] baseURL] , self.mapID];
if (token && token.length > 0) {
tileJSONURLString = [tileJSONURLString stringByAppendingFormat:@"?access_token=%@", token];
completion([NSURL URLWithString:tileJSONURLString]);
} else {
completion(nil);
}
}];
}
#pragma mark Geocoding
- (void)forwardGeocodingWithQueryString:(NSString *)query
parameters:(CSQueryParameters *)parameters
completion:(void (^)(NSArray *results, NSError *error))completion
{
NSMutableString *URLString = [NSMutableString stringWithFormat:@"%@/geocode/%@/%@", [[CSAuthenticationManager sharedManager] baseURL], self.mapID, query];
if (parameters != nil) {
[URLString appendString:@"?"];
[parameters.params enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if (key > 0) {
[URLString appendString:@"&"];
}
[URLString appendFormat:@"%@=%@", key, obj];
}];
}
NSURL *URL = [NSURL URLWithString:[URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[[CSAuthenticationManager sharedManager] savedAccessToken:^(NSString *token) {
if (token) {
[request setValue:[NSString stringWithFormat:@"Bearer %@", token] forHTTPHeaderField:@"Authorization"];
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if ([(NSHTTPURLResponse *)response statusCode] == HTTP_401_NOT_AUTHORIZED) {
NSString *description = NSLocalizedString(INVALID_CREDINTIAL, @"");
NSError *responseError = [NSError errorWithDomain:NSCocoaErrorDomain code:kCFURLErrorUserCancelledAuthentication userInfo:@{NSLocalizedDescriptionKey: description}];
completion(nil, responseError);
} else {
if (error != nil) {
completion(nil, error);
} else {
NSError *serializationError;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&serializationError];
if (serializationError == nil) {
NSArray *output = [NSArray array];
if ([json.allKeys containsObject:@"results"]) {
NSArray *results = [json objectForKey:@"results"];
output = results;
}
completion(output, nil);
}
else {
completion(nil, serializationError);
}
}
}
}] resume];
} else {
NSString *description = NSLocalizedString(TOKEN_NOT_PROVIDED, @"");
NSError *error = [[NSError alloc] initWithDomain:NSCocoaErrorDomain code:TOKEN_NOT_PROVIDED_CODE userInfo:@{NSLocalizedDescriptionKey: description}];
completion(nil, error);
}
}];
}
- (void)reverseGeocodingWithCoordinate:(CLLocationCoordinate2D)coordinate
completion:(void (^)(NSDictionary *results, NSError *error))completion
{
NSMutableString *URLString = [NSMutableString stringWithFormat:@"%@/geocode/%@/%@,%@.json",
[[CSAuthenticationManager sharedManager] baseURL], self.mapID, @(coordinate.latitude), @(coordinate.longitude)];
NSURL *URL = [NSURL URLWithString:[URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[[CSAuthenticationManager sharedManager] savedAccessToken:^(NSString *token) {
if (token) {
[request setValue:[NSString stringWithFormat:@"Bearer %@", token] forHTTPHeaderField:@"Authorization"];
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if ([(NSHTTPURLResponse *)response statusCode] == HTTP_401_NOT_AUTHORIZED) {
NSString *description = NSLocalizedString(INVALID_CREDINTIAL, @"");
NSError *responseError = [NSError errorWithDomain:NSCocoaErrorDomain code:kCFURLErrorUserCancelledAuthentication userInfo:@{NSLocalizedDescriptionKey: description}];
completion(nil, responseError);
} else {
if (error != nil) {
completion(nil, error);
} else {
NSError *serializationError;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&serializationError];
if (serializationError == nil) {
NSDictionary *output = [NSDictionary dictionary];
if ([json.allKeys containsObject:@"result"]) {
NSDictionary *result = [json objectForKey:@"result"];
output = result;
}
}
else {
completion(nil, serializationError);
}
}
}
}] resume];
} else {
NSString *description = NSLocalizedString(TOKEN_NOT_PROVIDED, @"");
NSError *error = [[NSError alloc] initWithDomain:NSCocoaErrorDomain code:TOKEN_NOT_PROVIDED_CODE userInfo:@{NSLocalizedDescriptionKey: description}];
completion(nil, error);
}
}];
}
@end
#pragma mark
@implementation CSQueryParameters
- (id)init
{
self = [super init];
if (self != nil) {
self.params = [NSMutableDictionary dictionary];
}
return self;
}
- (void)addCity:(NSString *)city
{
[self.params setObject:city forKey:@"city"];
}
- (void)addLimit:(NSUInteger)limit
{
[self.params setObject:@(limit) forKey:@"limit"];
}
- (void)addDistance:(CLLocationDistance)distance
{
[self.params setObject:@(distance) forKey:@"distance"];
}
- (void)addLocationWithCoordinate:(CLLocationCoordinate2D)coordinate
{
[self.params setObject:[NSString stringWithFormat:@"%@,%@", @(coordinate.latitude), @(coordinate.longitude)] forKey:@"location"];
}
@end
//
// CSMapSource.m
// Pods
//
// Created by Emad A. on 30/01/2015.
//
//
#import "CSMapSource.h"
#import "CSAuthenticationManager.h"
#define HTTP_404_NOT_FOUND 404
#define HTTP_401_NOT_AUTHORIZED 401
#pragma mark - CSQueryParameters Private Interface
#pragma mark
@interface CSQueryParameters ()
@property (nonatomic, strong) NSMutableDictionary *params;
@end
#pragma mark - CSMapSource Private Interface
#pragma mark
@interface CSMapSource () <NSURLConnectionDataDelegate>
@property (nonatomic, assign) NSInteger try;
@property (nonatomic, copy) NSString *mapId;
@property (nonatomic, strong) NSDictionary *info;
@property (nonatomic, strong) NSURLConnection *forwardGeocodingURLConnection;
@property (nonatomic, strong) NSMutableData *forwardGeocodingResponseData;
@property (nonatomic, copy) void (^forwardGeocodingCompletion)(NSArray *results, NSError *error);
@property (nonatomic, strong) NSURLConnection *reverseGeocodingURLConnection;
@property (nonatomic, strong) NSMutableData *reverseGeocodingResponseData;
@property (nonatomic, copy) void (^reverseGeocodingCompletion)(NSDictionary *result, NSError *error);
@end
#pragma mark - CSMapSource Implementation
#pragma mark
@implementation CSMapSource
- (id)initWithMapId:(NSString *)mapId
{
return [self initWithMapId:mapId enablingDataOnMapView:nil];
}
- (id)initWithMapId:(NSString *)mapId enablingDataOnMapView:(RMMapView *)mapView
{
self = [super init];
if (self != nil) {
self.mapId = mapId;
if (mapView != nil) {
mapView.tileSource = self;
}
}
return self;
}
- (NSURL *)URLForTile:(RMTile)tile
{
NSNumber *x = [NSNumber numberWithInteger:tile.x];
NSNumber *y = [NSNumber numberWithInteger:tile.y];
NSNumber *z = [NSNumber numberWithInteger:tile.zoom];
if (!self.info && ![self loadTileJSON]) {
return nil;
}
NSString *tileURLString = [self.info objectForKey:@"tiles"][0];
tileURLString = [tileURLString stringByReplacingOccurrencesOfString:@"{z}" withString:z.stringValue];
tileURLString = [tileURLString stringByReplacingOccurrencesOfString:@"{x}" withString:x.stringValue];
tileURLString = [tileURLString stringByReplacingOccurrencesOfString:@"{y}" withString:y.stringValue];
CGFloat scale = [[UIScreen mainScreen] scale];
if (scale > 1.0) {
tileURLString = [tileURLString stringByReplacingOccurrencesOfString:@".png" withString:@"@2x.png"];
}
else if (scale > 2.0) {
tileURLString = [tileURLString stringByReplacingOccurrencesOfString:@".png" withString:@"@3x.png"];
}
return [NSURL URLWithString:tileURLString];
}
- (UIImage*)imageForTile:(RMTile)tile inCache:(RMTileCache *)tileCache
{
__block UIImage *image = nil;
tile = [[self mercatorToTileProjection] normaliseTile:tile];
if (self.isCacheable) {
image = [tileCache cachedImage:tile withCacheKey:[self uniqueTilecacheKey]];
if (image != nil) {
return image;
}
}
dispatch_async(dispatch_get_main_queue(), ^(void) {
[[NSNotificationCenter defaultCenter] postNotificationName:RMTileRequested object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]];
});
NSURL *URL = [self URLForTile:tile];
for (NSUInteger try = 0; URL != nil && image == nil && try < self.retryCount; ++try) {
NSError *error = nil;
NSHTTPURLResponse *response = nil;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[request setTimeoutInterval:(self.requestTimeoutSeconds / (CGFloat)self.retryCount)];
image = [UIImage imageWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]];
if (response.statusCode == HTTP_404_NOT_FOUND) {
break;
}
else if (error.code == kCFURLErrorUserCancelledAuthentication) {
// Invalidating access token and tile json info in order to them again in next request
[[CSAuthenticationManager sharedManager] invalidateCredential];
[self setInfo:nil];
// Return NSNull here so that the RMMapTiledLayerView will try to fetch another tile if missingTilesDepth > 0
image = (UIImage *)[NSNull null];
break;
}
}
if (image && ![image isKindOfClass:[NSNull class]] && self.isCacheable) {
[tileCache addImage:image forTile:tile withCacheKey:[self uniqueTilecacheKey]];
}
dispatch_async(dispatch_get_main_queue(), ^(void) {
[[NSNotificationCenter defaultCenter] postNotificationName:RMTileRetrieved object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]];
});
return image;
}
#pragma mark
- (BOOL)loadTileJSON
{
NSString *tileJSONURLString = [NSString stringWithFormat:@"%@/tiles/%@.json", [[CSAuthenticationManager sharedManager] baseURL] , self.mapId];
tileJSONURLString = [tileJSONURLString stringByAppendingFormat:@"?access_token=%@", [[CSAuthenticationManager sharedManager] accessToken]];
NSError *error = nil;
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:tileJSONURLString]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:5];
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
if (error == nil) {
NSError *error = nil;
self.info = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
if (error != nil) {
[[NSNotificationCenter defaultCenter] postNotificationName:CSMapSourceErrorNotification
object:self
userInfo:@{@"error":error}];
return NO;
}
}
else {
[[NSNotificationCenter defaultCenter] postNotificationName:CSMapSourceErrorNotification
object:self
userInfo:@{@"error":error}];
return NO;
}
return YES;
}
#pragma mark
- (void)forwardGeocodingWithQueryString:(NSString *)query
parameters:(CSQueryParameters *)parameters
completion:(void (^)(NSArray *, NSError *))completion
{
self.forwardGeocodingCompletion = completion;
NSMutableString *URLString = [NSMutableString stringWithFormat:@"%@/geocode/%@/%@.json", [[CSAuthenticationManager sharedManager] baseURL], self.mapId, query];
if (parameters != nil) {
[URLString appendString:@"?"];
[parameters.params enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if (key > 0) {
[URLString appendString:@"&"];
}
[URLString appendFormat:@"%@=%@", key, obj];
}];
}
NSURL *URL = [NSURL URLWithString:[URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[request setValue:[NSString stringWithFormat:@"Bearer %@", [[CSAuthenticationManager sharedManager] accessToken]] forHTTPHeaderField:@"Authorization"];
if (self.forwardGeocodingURLConnection != nil) {
[self.forwardGeocodingURLConnection cancel];
}
self.forwardGeocodingURLConnection = [NSURLConnection connectionWithRequest:request delegate:self];
}
- (void)reverseGeocodingWithCoordinate:(CLLocationCoordinate2D)coordinate
completion:(void (^)(NSDictionary *, NSError *))completion
{
self.reverseGeocodingCompletion = completion;
NSMutableString *URLString = [NSMutableString stringWithFormat:@"%@/geocode/%@/%@,%@.json",
[[CSAuthenticationManager sharedManager] baseURL], self.mapId, @(coordinate.latitude), @(coordinate.longitude)];
NSURL *URL = [NSURL URLWithString:[URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[request setValue:[NSString stringWithFormat:@"Bearer %@", [[CSAuthenticationManager sharedManager] accessToken]] forHTTPHeaderField:@"Authorization"];
if (self.reverseGeocodingURLConnection != nil) {
[self.reverseGeocodingURLConnection cancel];
}
self.reverseGeocodingURLConnection = [NSURLConnection connectionWithRequest:request delegate:self];
}
#pragma mark - NSURLConnectionDataDelegate
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSError *error = nil;
if ([(NSHTTPURLResponse *)response statusCode] == HTTP_401_NOT_AUTHORIZED) {
[connection cancel];
error = [NSError errorWithDomain:@"Invalid credential" code:kCFURLErrorUserCancelledAuthentication userInfo:nil];
if ([connection isEqual:self.forwardGeocodingURLConnection]) {
self.forwardGeocodingCompletion(nil, error);
}
else if ([connection isEqual:self.reverseGeocodingURLConnection]) {
self.reverseGeocodingCompletion(nil, error);
}
}
else {
if ([connection isEqual:self.forwardGeocodingURLConnection]) {
self.forwardGeocodingResponseData = [[NSMutableData alloc] init];
}
else if ([connection isEqual:self.reverseGeocodingURLConnection]) {
self.reverseGeocodingResponseData = [[NSMutableData alloc] init];
}
}
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
if ([connection isEqual:self.forwardGeocodingURLConnection]) {
[self.forwardGeocodingResponseData appendData:data];
}
else if ([connection isEqual:self.reverseGeocodingURLConnection]) {
[self.reverseGeocodingResponseData appendData:data];
}
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSError *error = nil;
self.try = 0;
if ([connection isEqual:self.forwardGeocodingURLConnection]) {
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:self.forwardGeocodingResponseData options:0 error:&error];
if (error == nil && self.forwardGeocodingCompletion != nil) {
NSArray *output = [NSArray array];
if ([json.allKeys containsObject:@"results"]) {
NSArray *results = [json objectForKey:@"results"];
output = results;
}
self.forwardGeocodingCompletion(output, nil);
}
else {
self.forwardGeocodingCompletion(nil, error);
}
}
else if ([connection isEqual:self.reverseGeocodingURLConnection]) {
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:self.reverseGeocodingResponseData options:0 error:&error];
if (error == nil && self.reverseGeocodingCompletion != nil) {
NSDictionary *output = [NSDictionary dictionary];
if ([json.allKeys containsObject:@"result"]) {
NSDictionary *result = [json objectForKey:@"result"];
output = result;
}
self.reverseGeocodingCompletion(output, nil);
}
else {
self.reverseGeocodingCompletion(nil, error);
}
}
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
if ([connection isEqual:self.forwardGeocodingURLConnection] &&
self.forwardGeocodingCompletion != nil)
{
self.forwardGeocodingCompletion(nil, error);
}
else if ([connection isEqual:self.reverseGeocodingURLConnection] &&
self.reverseGeocodingCompletion != nil)
{
self.reverseGeocodingCompletion(nil, error);
}
}
#pragma mark
- (float)maxZoom
{
return [self.info[@"maxzoom"] floatValue] ?: 17;
}
- (float)minZoom
{
return [self.info[@"minzoom"] floatValue] ?: 11;
}
- (RMSphericalTrapezium)bounds
{
NSArray *infoBounds = self.info[@"bounds"];
RMSphericalTrapezium bounds;
bounds.northEast = CLLocationCoordinate2DMake([infoBounds[0] doubleValue], [infoBounds[1] doubleValue]);
bounds.northEast = CLLocationCoordinate2DMake([infoBounds[2] doubleValue], [infoBounds[3] doubleValue]);
return bounds;
}
- (NSString *)uniqueTilecacheKey
{
return @"CedarStudioMap";
}
- (NSString *)shortName
{
return @"CedarMaps Streets";
}
- (NSString *)longDescription
{
return @"CedarMaps covering the city of Tehran";
}
- (NSString *)shortAttribution
{
return @"© Cedar Studio Map";
}
- (NSString *)longAttribution
{
return @"Map data © Cedar Studio Map";
}
- (NSString *)version
{
return self.info[@"version"];
}
@end
#pragma mark
@implementation CSQueryParameters
- (id)init
{
self = [super init];
if (self != nil) {
self.params = [NSMutableDictionary dictionary];
}
return self;
}
- (void)addCity:(NSString *)city
{
[self.params setObject:city forKey:@"city"];
}
- (void)addLimit:(NSUInteger)limit
{
[self.params setObject:@(limit) forKey:@"limit"];
}
- (void)addDistance:(CGFloat)distance
{
[self.params setObject:@(distance) forKey:@"distance"];
}
- (void)addLocationWithLatitude:(CGFloat)latitude longitude:(CGFloat)longitude
{
[self.params setObject:[NSString stringWithFormat:@"%@,%@", @(latitude), @(longitude)] forKey:@"location"];
}
@end
......@@ -6,7 +6,7 @@
//
//
#import "Mapbox.h"
@import Mapbox;
#import "CSMapSource.h"
#import "CSMapKit.h"
#import "CSAuthenticationManager.h"
......@@ -4,36 +4,42 @@
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.
To use CedarStudio Maps 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>”];
[auth setCredentialsWithClientID:@"<your client Id>" clientSecret:@"<your client secret>"];
If your project has its own base URL which is not the one SDK provides, you can set that here:
auth.baseURL = @"http://api.myowncedarmaps.com/v1“;
Then an instance of CSMapSource should be initialised:
Then an instance of CSMapKit should be initialised:
CSMapSource *source = [[CSMapSource alloc] initWithMapId:@"cedarmaps.streets"];
CSMapKit *source = [[CSMapKit 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.
``MapID`` is the style that 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 later.
The map source instance will be used as tile source for a ``RMMapView``:
There is an asynchronous method in CSMapKit which provides you with ``styleURL``:
self.mapView.tileSource = source;
- (void)styleURLWithCompletion:(void (^) (NSURL *url))completion;
or initialised a ``CSMapSource`` with your instance of ``RMMapView``:
You then set the url as styleURL for ``MGLMapView``:
self.mapView.styleURL = url;
CSMapSource *source = [[CSMapSource alloc] initWithMapId:@"cedarmaps.streets" enablingDataOnMapView:self.mapView];
or initialise a ``MGLMapView`` with the url:
self.mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 300, 400) styleURL:url];
``CSMapSource`` has two methods for forward geocoding and reverse geocoding that returne a ``NSArray`` and ``NSDictionary`` respectively as soon as their job get done.
``CSMapKit`` has two methods for forward geocoding and reverse geocoding that return a ``NSArray`` and ``NSDictionary`` respectively as soon as their job gets 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.
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)requestAccessTokenFromServer:(void (^)(NSString *token, NSError *error))completion;`` of ``CSAuthenticationManager`` class.
Example projects for both ``Objective C`` and ``Swift`` are included.
## Requirements
......@@ -41,14 +47,16 @@ In case you have got a credential error with ``nil`` as the result, there might
## Installation
CedarMap is available through [CocoaPods](http://cocoapods.org). To install
CedarMaps is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
pod "CedarMap"
pod 'CedarMaps'
## Author
CedarStudio ®
## License
CedarMap is available under the MIT license. See the LICENSE file for more info.
CedarMaps 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