Commit 8901206b authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

applemap

parent 684ba8e8
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
// //
#import "ZJBaseMapViewController.h" #import "ZJBaseMapViewController.h"
#import <MapKit/MapKit.h>
@interface ZJBaseMapViewController ()<MAMapViewDelegate, XMPopupListViewDelegate> @interface ZJBaseMapViewController ()<MAMapViewDelegate, XMPopupListViewDelegate, MKMapViewDelegate>
@property (nonatomic, strong) MAMapView *mapView; @property (nonatomic, strong) MKMapView *mapView;
//@property (nonatomic, strong) MAMapView *mapView;
@property (nonatomic, strong) UIButton *gpsButton; @property (nonatomic, strong) UIButton *gpsButton;
@property (nonatomic, strong) ZJMapViewPersonCardView *cardView; @property (nonatomic, strong) ZJMapViewPersonCardView *cardView;
...@@ -40,41 +42,32 @@ ...@@ -40,41 +42,32 @@
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self getFriendList]; [self getFriendList];
}); });
if ([ZJUserInfoManager CNLanguage]) {
self.mapView.mapLanguage = @0;
[self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(0)];
}else{
self.mapView.mapLanguage = @1;
[self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(1)];
}
} }
- (void)viewWillAppear:(BOOL)animated{ - (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated]; [super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:true animated:true]; [self.navigationController setNavigationBarHidden:true animated:true];
if ([ZJUserInfoManager CNLanguage]) {
self.mapView.mapLanguage = @0;
[self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(0)];
}else{
self.mapView.mapLanguage = @1;
[self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(1)];
}
} }
- (void)setupUI{ - (void)setupUI{
///初始化地图 ///初始化地图
self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds]; self.mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
self.mapView.mapType = 0; self.mapView.mapType = 0;
_mapView.showsWorldMap = @YES; // _mapView.showsWorldMap = @YES;
[self.mapView performSelector:@selector(setShowsWorldMap:) withObject:@(YES)]; // [self.mapView performSelector:@selector(setShowsWorldMap:) withObject:@(YES)];
if ([ZJUserInfoManager CNLanguage]) {
// self.mapView.mapLanguage = @0;
// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(0)];
}else{
// self.mapView.mapLanguage = @1;
// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(1)];
}
_mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
///把地图添加至view ///把地图添加至view
[self.view addSubview: _mapView]; [self.view addSubview: _mapView];
_mapView.delegate = self; _mapView.delegate = self;
_mapView.zoomLevel = 14; // _mapView.zoomLevel = 14;
_mapView.showsScale = false; _mapView.showsScale = false;
_mapView.showsCompass = false; _mapView.showsCompass = false;
...@@ -126,29 +119,29 @@ ...@@ -126,29 +119,29 @@
}; };
} }
- (void)mapView:(UIView *)mapView regionDidChangeAnimated:(BOOL)animated { //- (void)mapView:(UIView *)mapView regionDidChangeAnimated:(BOOL)animated {
// if(mapView.isHidden) { //// if(mapView.isHidden) {
// return; //// return;
// } //// }
////
//// if(self.isSwitching) {
//// self.isSwitching = NO;
//// return;
//// }
//
//// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(1)];
//// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(0)];
// //
// if(self.isSwitching) { // if([mapView isKindOfClass:[MAMapView class]]) {
// self.isSwitching = NO; // if(!AMapDataAvailableForCoordinate(self.mapView.centerCoordinate)) {
// return; //
// }
// } else {
// if(AMapDataAvailableForCoordinate(self.mapView.centerCoordinate)) {
//
// }
// } // }
//}
// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(1)];
// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(0)];
if([mapView isKindOfClass:[MAMapView class]]) {
if(!AMapDataAvailableForCoordinate(self.mapView.centerCoordinate)) {
}
} else {
if(AMapDataAvailableForCoordinate(self.mapView.centerCoordinate)) {
}
}
}
#pragma mark 好友列表 #pragma mark 好友列表
- (void)getFriendList{ - (void)getFriendList{
...@@ -251,7 +244,7 @@ ...@@ -251,7 +244,7 @@
MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init]; MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init];
pointAnnotation.coordinate = CLLocationCoordinate2DMake(lat, lon); pointAnnotation.coordinate = CLLocationCoordinate2DMake(lat, lon);
pointAnnotation.title = @"latestLocation"; pointAnnotation.title = @"latestLocation";
[_self.mapView addAnnotation:pointAnnotation]; [_self.mapView addAnnotation:(id<MKAnnotation>)pointAnnotation];
[_self.mapView setCenterCoordinate:pointAnnotation.coordinate animated:false]; [_self.mapView setCenterCoordinate:pointAnnotation.coordinate animated:false];
}else{ }else{
...@@ -279,6 +272,19 @@ ...@@ -279,6 +272,19 @@
annotationView.enabled = NO; annotationView.enabled = NO;
return annotationView; return annotationView;
} }
else if([annotation isKindOfClass:[MKUserLocation class]]){
NSString *pointReuseIndetifier = @"pointReuseIndetifier3";
MKAnnotationView *annotationView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:pointReuseIndetifier];
if (annotationView == nil) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:pointReuseIndetifier];
annotationView.canShowCallout = YES;
}
annotationView.image = [UIImage imageNamed:@"userPosition"];
annotationView.enabled = NO;
return (MAAnnotationView *)annotationView;
}
return nil; return nil;
} }
......
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