LocationViewController.m 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. //
  2. // LocationViewController.m
  3. // Apex Mobile
  4. //
  5. // Created by Ray on 14-2-26.
  6. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "LocationViewController.h"
  9. //#import <GoogleMaps/GoogleMaps.h>
  10. #import <Contacts/Contacts.h>
  11. #import <ContactsUI/ContactsUI.h>
  12. @interface LocationViewController ()
  13. //@property (strong,nonatomic) NSString* locations ;
  14. @end
  15. @implementation LocationViewController{
  16. GMSMapView *mapView_;
  17. }
  18. - (BOOL)shouldAutorotate
  19. {
  20. return YES;
  21. }
  22. - (NSUInteger)supportedInterfaceOrientations
  23. {
  24. return UIInterfaceOrientationMaskPortrait;
  25. }
  26. - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
  27. {
  28. return UIInterfaceOrientationPortrait;
  29. }
  30. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  31. {
  32. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  33. if (self) {
  34. self.showNavigation = false;
  35. // Custom initialization
  36. }
  37. return self;
  38. }
  39. //- (void)viewWillAppear:(BOOL)animated
  40. //{
  41. // if(self.showNavigation==false)
  42. // [self.navigationController setNavigationBarHidden:true];
  43. //}
  44. //- (void)viewWillDisappear:(BOOL)animated
  45. //{
  46. // if(self.showNavigation==false)
  47. // [self.navigationController setNavigationBarHidden:false];
  48. //}
  49. - (void)viewDidLoad
  50. {
  51. [super viewDidLoad];
  52. [self updateLocation];
  53. // Create a GMSCameraPosition that tells the map to display the
  54. // coordinate -33.86,151.20 at zoom level 6.
  55. // GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
  56. // longitude:151.20
  57. // zoom:6];
  58. // mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  59. // mapView_.myLocationEnabled = YES;
  60. // self.view = mapView_;
  61. //
  62. // // Creates a marker in the center of the map.
  63. // GMSMarker *marker = [[GMSMarker alloc] init];
  64. // marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
  65. // marker.title = @"Sydney";
  66. // marker.snippet = @"Australia";
  67. // marker.map = mapView_;
  68. GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:39.833333
  69. longitude:-98.3583333
  70. zoom:2.5
  71. bearing:0
  72. viewingAngle:0];
  73. mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  74. mapView_.myLocationEnabled = YES;
  75. mapView_.delegate = self;
  76. mapView_.translatesAutoresizingMaskIntoConstraints = NO;
  77. [self.view addSubview:mapView_];
  78. NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:mapView_
  79. attribute:NSLayoutAttributeTop
  80. relatedBy:NSLayoutRelationEqual
  81. toItem:self.topLayoutGuide
  82. attribute:NSLayoutAttributeBottom
  83. multiplier:1.0
  84. constant:0];
  85. NSLayoutConstraint *left = [NSLayoutConstraint constraintWithItem:mapView_
  86. attribute:NSLayoutAttributeLeft
  87. relatedBy:NSLayoutRelationEqual
  88. toItem:self.view
  89. attribute:NSLayoutAttributeLeft
  90. multiplier:1.0
  91. constant:0];
  92. NSLayoutConstraint *bottom = [NSLayoutConstraint constraintWithItem:mapView_
  93. attribute:NSLayoutAttributeBottom
  94. relatedBy:NSLayoutRelationEqual
  95. toItem:self.bottomLayoutGuide
  96. attribute:NSLayoutAttributeTop
  97. multiplier:1.0
  98. constant:0];
  99. NSLayoutConstraint *right = [NSLayoutConstraint constraintWithItem:mapView_
  100. attribute:NSLayoutAttributeRight
  101. relatedBy:NSLayoutRelationEqual
  102. toItem:self.view
  103. attribute:NSLayoutAttributeRight
  104. multiplier:1.0
  105. constant:0];
  106. [self.view addConstraints:@[top,left,bottom,right]];
  107. // NSString *locations =@"Apex Maritime Co. (ORD) Inc.';'Chicago, IL\nUnited States';'42.051169,-88.0317029';'1900 E. Golf Road, Suite# 1105 Schaumburg, IL 60173';'Tel:+1 630 227-9818';'Fax:+1 630 227-9808';'Contact:\nSteve Yeh\nAileen Hsieh';'Email:\nsteve.yeh@apexshipping.com\naileen.hsieh@apexshipping.com';'Apex Maritime Co. (Hou) Inc.';'Houston, TX\nUnited States';'29.797022,-95.528827';'9610 Long Point Rd., Suite# 320 Houston, TX 77055';'Tel:+1 832 649-8198';'Fax:+1 832 649-8194';'Contact:\nAndy Pan\nTong Tong';'Email:\nandy.pan@apexshipping.com\ntong.tong@apexshipping.com';'Apex Maritime Co. (LAX) Inc.';'Los Angeles, CA\nUnited States';'34.0092709,-117.8463627';'565 Brea Canyon Road, Suite D Walnut, CA 91789';'Tel:+1 909 594-8828';'Fax:+1 909 594-9199';'Contact:\nVincent Luo\nSteven Chow';'Email:\nvincent.luo@apexshipping.com\nsteven.chow@apexshipping.com';'Apex Shipping Co., (NYC) Inc.';'New York, NY\nUnited States';'40.668404,-73.708329';'20 North Central Ave., 2nd FL, Suite# D Valley Stream, NY 11580';'Tel:516-200-9500';'Fax:516-200-9510';'Contact:\nWei Sun\nIrene Tseng';'Email:\nwei.sun@apexshipping.com\nirene.tseng@apexshipping.com';'Apex Maritime Co., Inc.';'San Francisco, CA\nUnited States';'37.646374,-122.398847';'206 Utah Ave. So. San Francisco, CA 94080';'Tel:650-589-2575';'Fax:650-589-8861';'Contact:\nJames Chu\nEsther Hui';'Email:\njames.chu@apexshipping.com\nesther.hui@apexshipping.com';'Apex Maritime Co., (PNW) Inc.';'Seattle, WA\nUnited States';'47.467763,-122.2321';'1107 S. W. Grady Way, Building B, Suite #110 Renton, WA 98055';'Tel:206-241-0771';'Fax:206-241-0823';'Contact:\nMike Langley\nRobert Bleck';'Email:\nmike.langley@apexshipping.com\nrobert.bleck@apexshipping.com';'Apex Maritime (Thailand) Co., Ltd.';'Bangkok, Thailand\nSoutheast Asia';'13.7308333,100.5241667';'138 Boonmitr Bldg., 12th Fl. Room B3, Silom Rd., Suriyawongse, Bangrak, Bangkok 10500';'Tel:+66 2 2634-3899 (Auto)';'Fax:+66 2 2634-3055\n66 2 2634-3056';'Contact:\nThikarn\nJaruwan\nSantana';'Email:\nthikarn@apexmaritime.co.th\njaruwan@apexmaritime.co.th\nsantana@apexmaritime.co.th';'PT. Apex Maritim Indonesia';'Cirebon, Indonesia\nSoutheast Asia';'-6.7166667,108.5666667';'HOTEL BUMI ASIH 2 ND FLOOR # 209 JL. WAHIDIN NO. 52 CIREBON';'Tel:+62 231 207278';'Fax:+62 231 207287';'Contact:\nSOEGIHARTO';'Email:\napex_cirebon@apex-indonesia.com';'Apex Vietnam';'Da Nang, Vietnam\nSoutheast Asia';'16.0641802,108.1873407';'3 FL, 39-41 Quang Trung Street Hai Chau Dist., Danang City, Vietnam';'Tel:+84 511 3896403';'Fax:+84 511 3823563';'Contact:\nMs. LAI';'Email:\ndanang@apexshipping.com.vn';'Apex Vietnam';'Haiphong, Vietnam\nSoutheast Asia';'20.861361,106.679802';'6th FL, 452 Le Thanh Tong Street Ngo Quyen District, Haiphong City, Vietnam';'Tel:+84 31 3750152';'Fax:+84 31 3836796';'Contact:\nMr. Nguyen Nhat Tan\nMr. Nguyen Nhat Huy';'Email:\nhaiphong@apexshipping.com.vn';'Apex Vietnam';'Hanoi, Vietnam\nSoutheast Asia';'21.0333333,105.85';'2nd FL. 108 Lo Duc Street. Hai Ba Trung District. Hanoi City, Vietnam';'Tel:+84 4 3971-9128';'Fax:+84 4 3971-9129';'Contact:\nMs. Le Thu Phuong';'Email:\nhanoi@apexshipping.com.vn';'Maritime Bank Tower ';'Ho Chi Minh City, Vietnam\nSoutheast Asia';'10.7685558,106.7012357';'Maritime Bank Tower 22th floor, room 02 180-192 Nguyen Cong Tru St., District 1 Hochiminh City, Vietnam';'Tel:+84 8 3914 2224';'Fax:+84 8 3914 3228\n3229';'Contact:\nThomas Phong';'Email:\nthomas@apexshipping.com.vn';'PT. Apex Shipping Indonesia';'Jakarta, Indonesia\nSoutheast Asia';'-6.225246,106.597423';'JIn. Bulevar Gajah Mada No. 2087 Lippo Cyberpark, Lippo Karawaci Tangerang 15811, Indonesia';'Tel:+62 21 558-2427';'Fax:+62 21 5577-1362';'Contact:\nNigolas Sjahputra\nUmi';'Email:\nnigolas@apex-indonesia.com\numi@apex-indonesia.com';'Apex Container Line (M) SDN BHD';'Malaysia\nSoutheast Asia';'1.3814563,103.4800838';'Suite 23A-05, level 23A, City Square, Jln Wong Ah Fook, 80000 Johor Bahru, Hohor, West Malaysia.';'Tel:(60) 7 222-2248 ( 6 lines)';'Fax:(60) 7 222-2278 (2 lines)';'Contact:\nFong Yee Chong';'Email:\nchloe.chong@apexshipping.com.my';'PT. Apex Maritim Indonesia';'Semarang, Indonesia\nSoutheast Asia';'-7.0016889,110.4331614';'RUKO METRO PLAZA JL. MT. HARYONO 970 BLOK C-7';'Tel:+62 24 844-7555';'Fax:+62 24 844-7666';'Contact:\nM. AYUB';'Email:\nm_ayub@apex-indonesia.com';'PT. Apex Maritim Indonesia';'Surabaya, Indonesia\nSoutheast Asia';'-7.289166,112.734398';'RUKO PERMATA BINTORO JL. TAMAN KETAMPON NO. 87 SURABAYA �C INDONESIA';'Tel:+62 31 566-1144';'Fax:+62 31 566-8289\n+62 31 566-9933';'Contact:\nIKA';'Email:\nika_setiawan@apex-indonesia.com';'Apex Maritime (Dalian) Co., Ltd.';'Dalian, China\nNorthern China';'38.9218515,121.6561693';'Room 201 No.1-3 No.112 Zhigong Street, Zhongshan Dis. Dalian, China';'Tel:+86 411 88866116 (Main)';'Fax:+86 411 82717900 (OP Dep.)';'Contact:\nWillis Yan �C +86 411 88866118\nJulia Guan �C +86 411 88866136';'Email:\nwillis.yan@apexshipping.com.cn\njulia.guan@apexshipping.com.cn';'Apex Maritime (Lianyungang) Co., Ltd.';'Lianyungang, China\nNorthern China';'34.596544,119.221282';'Room 715, No. 1 Street Building. Wangtian Haicheng Square. Xugou Lianyungang, Jiangsu, China';'Tel:+86 518 8223-3218\n+86 518 8223-3219';'Fax:+86 518 8223-3220';'Contact:\nZena Zheng';'Email:\nzena.zheng@apexshipping.com.cn';'Qingdao Apex Shipping Co., Ltd.';'Qingdao, China\nNorthern China';'36.0565576,120.3709705';'Suite 1903, No. 5 Donghai West Road Qingdao City, 266071, Shandong Province, China';'Tel:+86 532 85708982, 85708595, 85708109, 81979902';'Fax:+86 532 85708110';'Contact:\nFrank Song\nJennifer Liu';'Email:\nfrank.song@apexshipping.com.cn\njennifer.liu@apexshipping.com.cn';'Apex Maritime (Tianjin) Co., Ltd.';'Tianjin, China\nNorthern China';'39.1186127,117.1973693';'Room 3506, The Exchange North Tower, 189 Nanjin Rd. Tianjin, China';'Tel:+86 22 5886 3000';'Fax:+86 22 5886 3006\n5886 3008';'Contact:\nLucy Diao\nMandy Miao';'Email:\nlucy.diao@apexshipping.com.cn\nmandy.miao@apexshipping.com.cn';'Apex Maritime (Xian) Co., Ltd.';'Xian, China\nNorthern China';'34.2368419,108.8988572';'Room 912, Building C, Fortune Center II Gao Xin Third Rd., Hi-Tech Development Zone Xian City, Shaanxi Province,China 710075';'Tel:+86 29 65676809\n65676810\n65676811\n65676812';'Fax:+86 29 65676805';'Contact:\nKaren Huang';'Email:\nkaren.huang@apexshipping.com.cn';'Apex Maritime (Yantai) Co., Ltd.';'Yantai, China\nNorthern China';'37.5422926,121.3947602';'Room 2301, Huaxia Media Mansion, No. 53 North Ave. Yantai City,Shandong Province,China 264001';'Tel:+86 535 623-1345';'Fax:+86 535 623-4630';'Contact:\nJoey Yan';'Email:\njoey.yan@apexshipping.com.cn';'Apex Maritime (Chongqing) Co., Ltd.';'Chongqing, China\nEastern China';'29.5716184,106.531413';'Room 6, Floor 23, South Tower, Shijiyinghuang Building No. 38, North Jianxin Rd, Jiangbei District Chongqing 400020, China';'Tel:+86 23 8819 2009';'Fax:+86 23 8819 2036';'Contact:\nCindy Zeng\nLisa Xie';'Email:\ncindy.zeng@apexshipping.com.cn\nlisa.xie@apexshipping.com.cn';'Apex Maritime (Nanjing) Co., Ltd.';'Nanjing, China\nEastern China';'32.043114,118.789098';'Room D2, 18th Floor No.89 Hanzhong Road, Nanjing 210029, Jiangsu, China';'Tel:+86 25 84845871';'Fax:+86 25 84845879';'Contact:\nWinter Zhu';'Email:\nwinter.zhu@apexshipping.com.cn';'Apex Maritime (Ningbo) Co., Ltd.';'Ningbo, China\nEastern China';'29.8651695,121.5573647';'Rm 902, China Life Building No. 777 Lingqiao Road Ningbo 315010, China';'Tel:+86 574 8768 6310';'Fax:+86 574 8768 6314';'Contact:\nMr. Jason Sun';'Email:\njason.sun@apexshipping.com.cn';'Apex Maritime (Shanghai) Co., Ltd.';'Shanghai, China\nEastern China';'31.1668495,121.5430195';'RM 1211, WangJiao Plaza, 175, East Yianan Road, Shanghai 200002, China';'Tel:+86 21 6336 2020';'Fax:+86 21 53930630, 63563585, 63269809';'Contact:\nHali Huang';'Email:\nhali.huang@apexshipping.com.cn\njennifer.yu@apexshipping.com.cn';'Apex Maritime (Wuhan) Co., Ltd.';'Wuhan, China\nEastern China';'30.5952142,114.2977709';'Rm 1201, Truroll Plaza Wusheng Road Wuhan 430030, China.';'Tel:+86 27 8551 8817';'Fax:+86 27 8551 8882';'Contact:\nKatherine Lee';'Email:\nkatherine.lee@apexshipping.com.cn';'Apex Maritime (Fuzhou) Co., Ltd.';'Fuzhou, China\nSouthern China';'26.085417,119.294304';'Room A, 10\nF, Block No. 2, Hongyangxincheng Building No. 118 East Yangqiao Road Fuzhou 350001, China';'Tel:+86 591 87275810';'Fax:+86 591 87275890';'Contact:\nHelen Zhang';'Email:\nhelen.zhang@apexshipping.com.cn';'Apex Maritime (Guangzhou)';'Guangzhou, China\nSouthern China';'23.1345288,113.3079438';'Room 13B, Tower A Guangdong International Building No. 339 Huanshi Dong Road, Yuexiu District Guangzhou City, China';'Tel:+86-20-2237-8671';'Fax:+86-20-2237-8677';'Contact:\nBondy Zhang';'Email:\nbondy.zhang@apexshipping.com.cn';'Apex Maritime (HK) Co., Ltd.';'Hong Kong\nSouthern China';'22.281076,114.175695';'Room 1407-08, Harbour Centre 25 Harbour Rd. Wanchai, Hong Kong';'Tel:852-3188-9666';'Fax:852-3188-9555';'Contact:\nMartin Siu\nAndy Wong';'Email:\nmartin.siu@apexshipping.com.hk\nandy.wong@apexshipping.com.hk';'Apex Maritime (Shenzhen) Co., Ltd.';'Shenzhen, China\nSouthern China';'22.5427078,114.0710992';'Room 802, 8\nF., New China Insurance Edifice Mintian Rd., Futian District Shenzhen City, China 518026';'Tel:+86-755-8826-4001';'Fax:+86-755-8826-4014';'Contact:\nJames Zhuo\nShirley Xia';'Email:\njames.zhuo@apexshipping.com.cn\nshirley.xia@apexshipping.com.cn';'Apex Maritime (XMN) Co., Inc.';'Xiamen, China\nSouthern China';'24.462809,118.075456';'24H, International Plaza No. 8 Lujiang Rd. Xiamen 361001, China';'Tel:+86-592-261-8066';'Fax:+86-592-261-8070';'Contact:\nHelen Zhang';'Email:\nhelen.zhang@apexshipping.com.cn';'Apex Maritime (HK) Co., Ltd. (Zhongshan Branch)';'Zhongshan, China\nSouthern China';'22.501821,113.397235';'Room 07-08, 10\nF., Da Dong Yu Commerce Center Boai 5 Road, Zhongshan City, PRC';'Tel:+86 760 2 3889966\n+86 760 2 3889961';'Fax:+86 760 2 3889969';'Contact:\nAndy Shan';'Email:\nandy.shan@apexshipping.com.cn';'Apex Maritime India Pvt. Ltd.';'New Delhi\nIndia';'28.6244285,77.1349161';'CB 385 B First Floor, Ring Road Naraina, New Delhi 110028';'Tel:+91 98 11 123333';'Fax:';'Contact:\n';'Email:\ngt@apexshipping.in';'Apex Shipping B.V.';'Rotterdam, Netherlands\nEurope';'51.8637994,4.4348681';'Achterdijk 51-55 3161 EB Rhoon The Netherlands';'Tel:+31 10 8208801';'Fax:+31 10 8208802';'Contact:\nRon Reuver\nJohn Born';'Email:\nron.reuver@apexshipping.nl\njohn.born@apexshipping.nl";
  108. // NSArray *parts =[locations componentsSeparatedByString:NSLocalizedString(@"';'", nil)];
  109. [self addLocation];
  110. /* map.setInfoWindowAdapter(new CustomWindowAdapter());
  111. map.moveCamera(CameraUpdateFactory.newCameraPosition(US));
  112. map.setOnMarkerClickListener(this);
  113. map.setOnInfoWindowClickListener(this);*/
  114. }
  115. - (void)didReceiveMemoryWarning
  116. {
  117. [super didReceiveMemoryWarning];
  118. // Dispose of any resources that can be recreated.
  119. }
  120. - (void)mapView:(GMSMapView *)mapView
  121. didTapInfoWindowOfMarker:(GMSMarker *)marker
  122. {
  123. DebugLog(@"tap info window");
  124. // id ud = marker.userData;
  125. self.params = marker.userData;
  126. // [self addUnknown];
  127. [self showUnknown];
  128. // LocationDetailViewController *ViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LocationDetailViewController"];
  129. // ViewController.params = self.params;
  130. // self.aBNewPersonNav = [[UINavigationController alloc] initWithRootViewController:ViewController] ;
  131. // [self presentViewController:self.aBNewPersonNav animated:YES completion:^{
  132. //
  133. // }];
  134. // [self presentViewController:self.aBNewPersonNav animated:YES];
  135. //
  136. //
  137. //
  138. // [self.navigationController pushViewController:ViewController animated:YES];
  139. // [self performSegueWithIdentifier:@"DETAIL" sender:self];
  140. }
  141. //- (void)addUnknown
  142. //{
  143. //
  144. //
  145. //
  146. // // NSString* area = [self.params valueForKey:@"area"];
  147. // NSString* company = [self.params valueForKey:@"company"];
  148. // NSString* city = [self.params valueForKey:@"city"];
  149. // // double longitude = [[self.params valueForKey:@"longitude"] doubleValue];
  150. // // double latitude = [[self.params valueForKey:@"latitude"] doubleValue];
  151. // NSString* address = [self.params valueForKeyPath:@"address"];
  152. // NSString* telephone = [self.params valueForKeyPath:@"telephone"];
  153. // NSString* fax = [self.params valueForKeyPath:@"fax"];
  154. // // NSString* contact = [self.params valueForKeyPath:@"contact"];
  155. // NSString* email = [self.params valueForKeyPath:@"email"];
  156. //
  157. //
  158. //
  159. //
  160. //
  161. //
  162. //
  163. // CFStringRef cfscompany = CFStringCreateWithCString( kCFAllocatorDefault, [company UTF8String], kCFStringEncodingUTF8);
  164. // // CFStringRef cfsaddress = CFStringCreateWithCString( kCFAllocatorDefault, [address UTF8String], kCFStringEncodingUTF8);
  165. // // CFStringRef cfsaddress = CFStringCreateWithCString( kCFAllocatorDefault, [address UTF8String], kCFStringEncodingUTF8);
  166. // // CFStringRef cfsaddress = CFStringCreateWithCString( kCFAllocatorDefault, [address UTF8String], kCFStringEncodingUTF8);
  167. // // CFStringRef cfsaddress = CFStringCreateWithCString( kCFAllocatorDefault, [address UTF8String], kCFStringEncodingUTF8);
  168. //
  169. // CFErrorRef error =NULL;
  170. // ABRecordRef personRef=ABPersonCreate();
  171. //
  172. //
  173. // NSData *dataRef = UIImagePNGRepresentation([UIImage imageNamed:@"apex512"]);
  174. // ABPersonSetImageData(personRef, CFBridgingRetain(dataRef), &error);
  175. // // ABAddressBookAddRecord(iPhoneAddressBook, newPerson, &error);
  176. //
  177. // ABRecordSetValue(personRef, kABPersonOrganizationProperty, cfscompany, &error);
  178. // ABMutableMultiValueRef urlMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType);
  179. // ABMultiValueAddValueAndLabel(urlMultiValue,@"http://www.apexshipping.com", kABPersonHomePageLabel, NULL);
  180. // ABRecordSetValue(personRef, kABPersonURLProperty, urlMultiValue, &error);
  181. //
  182. //
  183. // ABMutableMultiValueRef multiaddress=ABMultiValueCreateMutable(kABMultiStringPropertyType);
  184. // //电话号码属于具有多个值的项(除此还有email、地址类)
  185. // NSMutableDictionary *addressDictionary = [[NSMutableDictionary alloc] init];
  186. // [addressDictionary setObject:address forKey:(NSString *) kABPersonAddressStreetKey];
  187. // [addressDictionary setObject:city forKey:(NSString *)kABPersonAddressCityKey];
  188. // // [addressDictionary setObject:@"IL" forKey:(NSString *)kABPersonAddressStateKey];
  189. // // [addressDictionary setObject:@"60654" forKey:(NSString *)kABPersonAddressZIPKey];
  190. // ABMultiValueAddValueAndLabel(multiaddress, CFBridgingRetain(addressDictionary), kABWorkLabel, NULL);
  191. //
  192. //
  193. // // CFStringRef cfsaddress = CFStringCreateWithCString( kCFAllocatorDefault, [address UTF8String], kCFStringEncodingUTF8);
  194. // // ABMultiValueAddValueAndLabel(multiaddress, cfsaddress, kABWorkLabel, NULL);
  195. // ABRecordSetValue(personRef, kABPersonAddressProperty, multiaddress, &error);
  196. //
  197. //
  198. // ABMutableMultiValueRef multiemail=ABMultiValueCreateMutable(kABMultiStringPropertyType);
  199. // //电话号码属于具有多个值的项(除此还有email、地址类)
  200. // NSArray* arremail = [email componentsSeparatedByString:NSLocalizedString(@"\r\n", nil)];
  201. // for(int i=0;i<arremail.count;i++)
  202. // {
  203. // ABMultiValueAddValueAndLabel(multiemail, CFStringCreateWithCString( kCFAllocatorDefault, [arremail[i] UTF8String], kCFStringEncodingUTF8), kABWorkLabel, NULL);
  204. // }
  205. // ABRecordSetValue(personRef, kABPersonEmailProperty, multiemail, &error);
  206. //
  207. // ABMutableMultiValueRef multiphone=ABMultiValueCreateMutable(kABMultiStringPropertyType);
  208. // //电话号码属于具有多个值的项(除此还有email、地址类)
  209. // NSArray* arrphone = [telephone componentsSeparatedByString:NSLocalizedString(@"\r\n", nil)];
  210. // for(int i=0;i<arrphone.count;i++)
  211. // {
  212. // ABMultiValueAddValueAndLabel(multiphone, CFStringCreateWithCString( kCFAllocatorDefault, [arrphone[i] UTF8String], kCFStringEncodingUTF8), kABWorkLabel, NULL);
  213. // }
  214. //
  215. // NSArray* arrfax = [fax componentsSeparatedByString:NSLocalizedString(@"\r\n", nil)];
  216. // for(int i=0;i<arrfax.count;i++)
  217. // {
  218. // ABMultiValueAddValueAndLabel(multiphone, CFStringCreateWithCString( kCFAllocatorDefault, [arrfax[i] UTF8String], kCFStringEncodingUTF8), kABPersonPhoneWorkFAXLabel, NULL);
  219. // }
  220. // ABRecordSetValue(personRef, kABPersonPhoneProperty, multiphone, &error);
  221. //
  222. //
  223. //
  224. // ABUnknownPersonViewController *unknown=[[ABUnknownPersonViewController alloc]init];
  225. // unknown.displayedPerson = personRef;
  226. // unknown.unknownPersonViewDelegate = self;
  227. // unknown.allowsActions = true;
  228. //
  229. // ABAddressBookRef addressBook = ABAddressBookCreate();
  230. // // CFStringRef cfName = CFSTR("小明");
  231. // NSArray *people = (__bridge NSArray *)(ABAddressBookCopyPeopleWithName(addressBook, cfscompany));
  232. //
  233. // if(people.count>0)
  234. // unknown.allowsAddingToAddressBook = false;
  235. // // unknown.displayedPerson=person;
  236. // // unknown.allowsAddingToAddressBook=YES;//允许添加
  237. //
  238. // // ABNewPersonViewController *npvc = [[ABNewPersonViewController alloc] init] ;
  239. // // // npvc.navigationItem.leftBarButtonItem = BARBUTTON(@"取消", @selector(addNewBackAction:));
  240. // // // self.aBNewPersonNav = [[UINavigationController alloc] initWithRootViewController:npvc] ;
  241. // // npvc.displayedPerson = personRef;
  242. // // npvc.newPersonViewDelegate = self;
  243. // // [self presentModalViewController:self.aBNewPersonNav animated:YES];
  244. //
  245. //
  246. // self.aBNewPersonNav = [[UINavigationController alloc] initWithRootViewController:unknown] ;
  247. // UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
  248. // // closeButton.title = @"Close";
  249. //
  250. // unknown.navigationItem.leftBarButtonItem = closeButton;
  251. //
  252. // unknown.navigationItem.title =[self.params valueForKey:@"company"];
  253. // [self presentViewController:self.aBNewPersonNav animated:YES completion:^{
  254. //
  255. // }];
  256. //
  257. //
  258. //// [self.navigationController pushViewController:unknown animated:YES];
  259. //
  260. //
  261. //
  262. //}
  263. - (void)showUnknown {
  264. NSString* company = [self.params valueForKey:@"company"];
  265. NSString* city = [self.params valueForKey:@"city"];
  266. NSString* address = [self.params valueForKeyPath:@"address"];
  267. NSString* telephone = [self.params valueForKeyPath:@"telephone"];
  268. NSString* fax = [self.params valueForKeyPath:@"fax"];
  269. NSString* email = [self.params valueForKeyPath:@"email"];
  270. UIImage *image = [UIImage imageNamed:@"apex512"];
  271. NSString *homePage = @"http://www.apexshipping.com";
  272. CNMutableContact *contact = [[CNMutableContact alloc] init];
  273. contact.imageData = UIImagePNGRepresentation(image);
  274. contact.organizationName = company;
  275. // url
  276. CNLabeledValue *homePageAddress = [CNLabeledValue labeledValueWithLabel:CNLabelURLAddressHomePage value:homePage];
  277. contact.urlAddresses = @[homePageAddress];
  278. // city
  279. CNMutablePostalAddress *postalAddress = [[CNMutablePostalAddress alloc] init];
  280. postalAddress.city = city;
  281. postalAddress.street = address;
  282. CNLabeledValue *postAddressValue = [CNLabeledValue labeledValueWithLabel:CNLabelWork value:postalAddress];
  283. contact.postalAddresses = @[postAddressValue];
  284. // email
  285. NSMutableArray *emailAdress = [NSMutableArray array];
  286. NSArray* arremail = [email componentsSeparatedByString:NSLocalizedString(@"\r\n", nil)];
  287. for(int i=0;i<arremail.count;i++)
  288. {
  289. CNLabeledValue *workEmail = [CNLabeledValue labeledValueWithLabel:CNLabelWork value:[arremail objectAtIndex:i]];
  290. [emailAdress addObject:workEmail];
  291. }
  292. contact.emailAddresses = emailAdress;
  293. NSMutableArray *phoneArray = [NSMutableArray array];
  294. // phone
  295. NSArray* arrphone = [telephone componentsSeparatedByString:NSLocalizedString(@"\r\n", nil)];
  296. for(int i=0;i<arrphone.count;i++)
  297. {
  298. CNPhoneNumber *phone = [[CNPhoneNumber alloc] initWithStringValue:[arrphone objectAtIndex:i]];
  299. CNLabeledValue *phoneLabel = [CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberMobile value:phone];
  300. [phoneArray addObject:phoneLabel];
  301. }
  302. // fax
  303. NSArray* arrfax = [fax componentsSeparatedByString:NSLocalizedString(@"\r\n", nil)];
  304. for(int i=0;i<arrfax.count;i++)
  305. {
  306. CNPhoneNumber *fax = [[CNPhoneNumber alloc] initWithStringValue:[arrfax objectAtIndex:i]];
  307. CNLabeledValue *faxLabel = [CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberWorkFax value:fax];
  308. [phoneArray addObject:faxLabel];
  309. }
  310. contact.phoneNumbers = phoneArray;
  311. self.contact = contact;
  312. // View
  313. CNContactViewController *contactVC = [CNContactViewController viewControllerForUnknownContact:contact];
  314. self.aBNewPersonNav = [[UINavigationController alloc] initWithRootViewController:contactVC] ;
  315. UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
  316. // UIBarButtonSystemItemSave,
  317. // UIBarButtonSystemItemAdd
  318. UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(onSaveClick:)];
  319. contactVC.navigationItem.rightBarButtonItem = saveButton;
  320. contactVC.navigationItem.leftBarButtonItem = closeButton;
  321. contactVC.navigationItem.title =[self.params valueForKey:@"company"];
  322. [self presentViewController:self.aBNewPersonNav animated:YES completion:^{
  323. }];
  324. }
  325. - (void)contactViewController:(CNContactViewController *)viewController didCompleteWithContact:(nullable CNContact *)contact
  326. {
  327. if(contact ==nil)
  328. [self.aBNewPersonNav popViewControllerAnimated:false];
  329. }
  330. - (void)onSaveClick:(UIButton *)sender {
  331. CNContactViewController *contactVC = [CNContactViewController viewControllerForNewContact:self.contact];
  332. contactVC.delegate = self;
  333. [self.aBNewPersonNav pushViewController:contactVC animated:false];
  334. // [self.aBNewPersonNav dismissViewControllerAnimated:true completion:^{
  335. // ;
  336. // }];
  337. }
  338. - (void)onCloseClick:(UIButton *)sender {
  339. [self.aBNewPersonNav dismissViewControllerAnimated:true completion:^{
  340. ;
  341. }];
  342. }
  343. -(void) addLocation
  344. {
  345. [mapView_ clear];
  346. self.Locations = [ApexMobileDB get_Location];
  347. UIImage *image;
  348. image = [UIImage imageNamed:@"ic_marker.png"];
  349. for (int i = 0; i < self.Locations.count ; i ++)
  350. {
  351. NSDictionary* location = self.Locations[i];
  352. NSString* area = [location valueForKey:@"area"];
  353. NSString* company = [location valueForKey:@"company"];
  354. NSString* city = [location valueForKey:@"city"];
  355. double longitude = [[location valueForKey:@"longitude"] doubleValue];
  356. double latitude = [[location valueForKey:@"latitude"] doubleValue];
  357. // NSString* address = [location valueForKeyPath:@"address"];
  358. // NSString* telephone = [location valueForKeyPath:@"telephone"];
  359. // NSString* fax = [location valueForKeyPath:@"fax"];
  360. // NSString* contact = [location valueForKeyPath:@"contact"];
  361. // NSString* email = [location valueForKeyPath:@"email"];
  362. // NSString *markertext = parts[i];
  363. // NSString *city = parts[i + 1];
  364. // NSString *postext = parts[i + 2];
  365. // NSArray *point = [postext componentsSeparatedByString:NSLocalizedString(@",", nil)];//postext.split(",");
  366. //
  367. // NSString *address = parts[i+3];
  368. // NSArray *tel = parts[i+4];
  369. // NSArray *fax = parts[i+5];
  370. // NSArray *contact = parts[i+6];
  371. // NSArray *email = parts[i+7];
  372. // NSMutableDictionary* params = [[NSMutableDictionary alloc]init];
  373. // [params setObject:markertext forKey:@"name"];
  374. // [params setObject:address forKey:@"addr"];
  375. // [params setObject:telephone forKey:@"tel"];
  376. // [params setObject:fax forKey:@"fax"];
  377. // [params setObject:contact forKey:@"contact"];
  378. // [params setObject:email forKey:@"email"];
  379. // // Creates a marker in the center of the map.
  380. GMSMarker *marker = [[GMSMarker alloc] init];
  381. marker.position = CLLocationCoordinate2DMake(latitude,longitude);
  382. marker.title = company;
  383. // NSString* snippet = [city stringByAppendingString:@"\n Click for more detail"];
  384. marker.snippet = [[NSString stringWithFormat:@"%@\n%@",city,area] stringByAppendingString:NSLocalizedString(@"ask_click", nil)];
  385. marker.map = mapView_;
  386. marker.userData = location;
  387. marker.icon = image;
  388. DebugLog(@"create marker title:%@ snippet:%@",marker.title,marker.snippet);
  389. }
  390. }
  391. -(void) updateLocation
  392. {
  393. // [self.params setValue:[NSString stringWithFormat:@"%ld",self.offset] forKey:@"offset"];
  394. // self.mum.center = self.view.center;
  395. //
  396. // NSTimeInterval animationDuration = 0.30f;
  397. // [UIView beginAnimations:@"ResizeView" context:nil];
  398. // [UIView setAnimationDuration:animationDuration];
  399. // self.prepageButton.enabled=false;
  400. // self.nextpageButton.enabled=false;
  401. // self.mum.hidden = false;
  402. // self.grid.hidden = true;
  403. //
  404. // [UIView commitAnimations];
  405. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  406. bool bupdate=[RANetwork UpdateServiceLocation];
  407. dispatch_async(dispatch_get_main_queue(), ^{
  408. if(bupdate)
  409. [self addLocation];
  410. // if(bupdate==true)
  411. // {
  412. //
  413. // }
  414. // else
  415. // {
  416. //
  417. // }
  418. // if(self.recordCount>=0)
  419. // {
  420. // if(self.recordCount<2000)
  421. // self.countView.title = [NSString stringWithFormat:@"%ld records",self.recordCount];
  422. // else
  423. // self.countView.title = @"2000+ records";
  424. // }
  425. // else
  426. // {
  427. // self.countView.title = @"Net error!";
  428. // }
  429. // if(self.offset<self.pageData.get_count||self.offset==0)
  430. // self.prepageButton.enabled=false;
  431. // else
  432. // self.prepageButton.enabled=true;
  433. // if(self.offset+self.pageData.get_count>=self.recordCount)
  434. // self.nextpageButton.enabled=false;
  435. // else
  436. // self.nextpageButton.enabled=true;
  437. // [self.grid initgrid :self.pageData];
  438. //
  439. // CGPoint p = self.grid.frame.origin;
  440. //
  441. //
  442. // self.mum.hidden = true;
  443. // self.grid.hidden = false;
  444. // [UIView commitAnimations];
  445. });
  446. });
  447. }
  448. //- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  449. //
  450. // if ([[segue identifier] isEqualToString:@"DETAIL"]) {
  451. //
  452. //
  453. //
  454. //
  455. // LocationDetailViewController *ViewController = segue.destinationViewController;
  456. //
  457. // ViewController.params = self.params;
  458. // }
  459. //}
  460. //- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
  461. // // if (marker == melbourneMarker_) {
  462. // UILabel * ret = [[UILabel alloc] init];
  463. // ret.text = @"textazaaaaaaa";
  464. // ret.backgroundColor = [UIColor whiteColor];
  465. // [ret sizeToFit];
  466. // return ret;
  467. // return [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"first"]];
  468. // // }
  469. //
  470. // return nil;
  471. //}
  472. @end