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

applemap

parent 684ba8e8
......@@ -7,10 +7,12 @@
//
#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) ZJMapViewPersonCardView *cardView;
......@@ -40,41 +42,32 @@
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[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{
[super viewWillAppear:animated];
[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{
///初始化地图
self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds];
self.mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
self.mapView.mapType = 0;
_mapView.showsWorldMap = @YES;
[self.mapView performSelector:@selector(setShowsWorldMap:) withObject:@(YES)];
// _mapView.showsWorldMap = @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;
///把地图添加至view
[self.view addSubview: _mapView];
_mapView.delegate = self;
_mapView.zoomLevel = 14;
// _mapView.zoomLevel = 14;
_mapView.showsScale = false;
_mapView.showsCompass = false;
......@@ -126,29 +119,29 @@
};
}
- (void)mapView:(UIView *)mapView regionDidChangeAnimated:(BOOL)animated {
// if(mapView.isHidden) {
// return;
// }
//- (void)mapView:(UIView *)mapView regionDidChangeAnimated:(BOOL)animated {
//// if(mapView.isHidden) {
//// 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) {
// self.isSwitching = NO;
// return;
// if([mapView isKindOfClass:[MAMapView class]]) {
// if(!AMapDataAvailableForCoordinate(self.mapView.centerCoordinate)) {
//
// }
// } 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 好友列表
- (void)getFriendList{
......@@ -251,7 +244,7 @@
MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init];
pointAnnotation.coordinate = CLLocationCoordinate2DMake(lat, lon);
pointAnnotation.title = @"latestLocation";
[_self.mapView addAnnotation:pointAnnotation];
[_self.mapView addAnnotation:(id<MKAnnotation>)pointAnnotation];
[_self.mapView setCenterCoordinate:pointAnnotation.coordinate animated:false];
}else{
......@@ -279,6 +272,19 @@
annotationView.enabled = NO;
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;
}
......
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