- (void)viewDidLoad
{
mapView=[MTMapView mapViewWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) Delegate:self];
if(searchRouteRsp==nil){
[UIHelp showHint:@"暂无商家" intView:self.view];
}
if(searchRouteRsp.dataArray!=nil){
NSLog(@"%d", searchRouteRsp.dataArray.count);
// MTAnnotationView *an2;
// MTLabel *label2;
for (int j=0; j<searchRouteRsp.dataArray.count; j++)
{
columnRespData=[searchRouteRsp.mColumnRespDataList objectAtIndex:j];
NSMutableArray *extendInfoArray=[searchRouteRsp.dataArray objectAtIndex:j];
NSMutableArray *Level2=[extendInfoArray objectAtIndex:0];
NSMutableDictionary *dataDictionary=[extendInfoArray objectAtIndex:1];
NSLog(@"Level2--%d", Level2.count);
MapExtendInfo *mlongitude=[Level2 objectAtIndex:1];
MapExtendInfo *mlatitude=[Level2 objectAtIndex:2];
NSLog(@"%@",mlongitude);
UIImage *my=[UIImage imageNamed:@"pinRed.png"];
CGRect imgFrame=CGRectMake(0, 0, my.size.width, my.size.height);
MTAnnotationView *an2=[MTAnnotationView annotationViewWithFrame:imgFrame UIImage:my Delegate:self];
// MTLabel *mtLabel=[MTLabel labelWithTitle:[NSString stringWithFormat:@"%@\r\n %@",columnRespData.mNode.nodename,[dataDictionary valueForKey:@"address"] ]Font:[UIFont fontWithName:@"STHeitik-Medium" size:18]];
MTLabel *mtLabel=[MTLabel labelWithTitle:@" " Font:[UIFont fontWithName:@"STHeitik-Medium" size:15]];
[mtLabel setFrame:CGRectMake(0, 0, 255, 105)];
UILabel *shopContent=[[UILabel alloc]initWithFrame:CGRectMake(3, 0, 250, 100)];
shopContent.backgroundColor=[UIColor clearColor];
shopContent.lineBreakMode=UILineBreakModeCharacterWrap;
shopContent.numberOfLines=0;
shopContent.text=[NSString stringWithFormat:@"%@\n地址:%@\n电话:%@", columnRespData.mNode.nodename, [dataDictionary valueForKey:@"address"],[dataDictionary valueForKey:@"telphone"]];
shopContent.font=[UIFont fontWithName:@"STHeitik-Medium" size:15];
shopContent.textColor=[UIColor whiteColor];
[mtLabel addSubview:shopContent];
// [mtLabel setLabelPoint:CGPointMake(-50, 30)];
[an2 addLabel:mtLabel];
NSLog(@"%@",mlatitude.attrvalue);
NSLog(@"%@",mlongitude.attrvalue);
if(mlatitude.attrvalue!=0)
{
}
// [an2 setUserInteractionEnabled:YES];
if([mlatitude.attrvalue floatValue]!=0&&[mlongitude.attrvalue floatValue]!=0)
{
[an2 setCoordinate:CGPointMake( [mlongitude.attrvalue floatValue],[mlatitude.attrvalue floatValue])];
}
[an2 setHotXY:CGPointMake(7, 34.5)];
[mapView addAnnotation:an2 ];
if(j==0)
{
tempLatitude=[mlatitude.attrvalue floatValue];
tempLongitude=[mlongitude.attrvalue floatValue];
}
}
}
CGPoint mapcenter=CGPointMake(tempLongitude,tempLatitude);
// CGPoint mapcenter=CGPointMake(116.39716f, 39.91669f);
// CGPoint mapcenter=CGPointMake(LATITUDE, LONGGITUDE);
CGSize mapsize=CGSizeMake(0.04f,0.03f);
CGRect region=CGRectMake(mapcenter.x, mapcenter.y, mapsize.width, mapsize.height);
[mapView setRegion:region animated:NO];
[mapView setCenterCoordinate:mapcenter animated:NO];
[self.view addSubview:mapView];
[self.view sendSubviewToBack:mapView];
[super viewDidLoad];
}