Permalink
Browse files

Changed Mapkit

  • Loading branch information...
prasadmb committed Apr 27, 2012
1 parent 33bcc43 commit a0491a7d843a1c8b02c2996ddf4e10a6b2102a25
@@ -31,8 +31,7 @@ - (id) initWithFrame:(CGRect) frame
routeView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 40, mapView.frame.size.width, mapView.frame.size.height)];
routeView.userInteractionEnabled = NO;
[mapView addSubview:routeView];
-
- self.lineColor = [UIColor blueColor];
+ self.lineColor = [UIColor colorWithRed:0.0 green:0.5 blue:1 alpha:0.6];
}
return self;
}
@@ -151,7 +150,7 @@ -(void) updateRouteView {
CGContextSetStrokeColorWithColor(context, lineColor.CGColor);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
- CGContextSetLineWidth(context, 3.0);
+ CGContextSetLineWidth(context, 10.0);
for(int i = 0; i < routes.count; i++) {
CLLocation* location = [routes objectAtIndex:i];
@@ -187,6 +186,48 @@ - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
[routeView setNeedsDisplay];
}
+-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
+(id <MKAnnotation>)annotation {
+
+ BOOL isGreen = YES;
+ //if([annotation isKindOfClass:[MKAnnotation class]])
+ // isGreen = NO;
+
+ MKPinAnnotationView *pinView = nil;
+ PlaceMark *pMark=annotation;
+ if([pMark.place.name isEqualToString:@"Current Location"])
+ isGreen=NO;
+ NSLog(@"Current Location:%@",annotation);
+ if (isGreen) {
+ static NSString *greenPin = @"greenPin";
+ pinView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:greenPin];
+ if (!pinView) {
+ pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:greenPin] autorelease];
+ pinView.pinColor = MKPinAnnotationColorGreen;
+ pinView.animatesDrop = NO;
+ pinView.canShowCallout = YES;
+ }
+ else
+ pinView.annotation = annotation;
+
+ }
+ else {
+ static NSString *purplePin = @"purplePin";
+ pinView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:purplePin];
+ if (!pinView) {
+ pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:purplePin] autorelease];
+ pinView.pinColor = MKPinAnnotationColorRed;
+ pinView.animatesDrop = NO;
+ pinView.canShowCallout = YES;
+ }
+ else
+ pinView.annotation = annotation;
+ }
+
+
+ return pinView;
+}
+
- (void)dealloc {
if(routes) {
[routes release];
@@ -13,9 +13,11 @@
@interface MapWithRoutesViewController : UIViewController {
CLLocation *destination;
+ NSString *destinationAddress;
}
-@property(nonatomic,retain) CLLocation *destination;
+@property(nonatomic,retain) CLLocation *destination;
+@property(nonatomic,retain) NSString *destinationAddress;
- (void) setDestination:(CLLocation *) aDestination;
- (void)cancel:(id)sender;
- (void) createTopBar;
@@ -11,7 +11,7 @@
@implementation MapWithRoutesViewController
@synthesize destination;
-
+@synthesize destinationAddress;
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
@@ -45,13 +45,13 @@ - (void)viewDidLoad {
source.name = @"Current Location";
source.description = @"";
//Ginza Latitirude & Longitude
- //source.latitude = 35.6707504;
- //source.longitude = 139.769467;
- source.latitude=currentLoc.coordinate.latitude;
- source.longitude=currentLoc.coordinate.longitude;
+ source.latitude = 35.6707504;
+ source.longitude = 139.769467;
+ //source.latitude=currentLoc.coordinate.latitude;
+ //source.longitude=currentLoc.coordinate.longitude;
Place* dest = [[[Place alloc] init] autorelease];
- dest.name = @"Destination";
- dest.description = @"Destination";
+ dest.name =destinationAddress;
+ //dest.description = @"Destination";
//dest.latitude = 1.3296047;
//dest.longitude = 103.8932174;
dest.latitude= self.destination.coordinate.latitude;
@@ -79,9 +79,10 @@ - (void) createTopBar {
}
- (void) setDestination:(CLLocation *) aDestination {
destination=aDestination;
- NSLog(@"Destinat");
}
-
+- (void) setDestinationAddress:(NSString *) aDestinationAddress {
+ destinationAddress=aDestinationAddress;
+}
- (void)cancel:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
@@ -279,7 +279,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
int time = (me/4000)*15;
cell.lblDistance.text =[NSString stringWithFormat:@" %.fm (徒歩%d分)",meters,time];
// Animate Arrow
- double radians=((([self bearingToLocation:storeLocation])- mHeading)*M_PI)/360;
+ double radians=((([self bearingToLocation:storeLocation])- mHeading)*M_PI)/180;
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
theAnimation.duration = 0.5f;
@@ -308,7 +308,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
int time = (me/4000)*15;
cell.lblDistance.text =[NSString stringWithFormat:@" %.fm (徒歩%d分)",meters,time];
// Animate Arrow
- double radians=((([self bearingToLocation:storeLocation])- mHeading)*M_PI)/360;
+ double radians=((([self bearingToLocation:storeLocation])- mHeading)*M_PI)/180;
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
theAnimation.duration = 0.5f;
@@ -18,6 +18,7 @@
//Added by MobiQuest team
float mHeading;
+ float mWebViewFlexibleHeight;
CLHeading *newHeadingObject;
NSString *currenDirection;
NSString *previousDirection;
@@ -71,4 +72,6 @@
- (void) sendEmail;
-(NSString *) shareKitMessage;
-(void) animateArrowImage;
+- (void)setUILabel:(UILabel *)myLabel withMaxFrame:(CGRect)maxFrame withText:(NSString *)theText usingVerticalAlign:(int)vertAlign;
+- (void) loadWebView;
@end
@@ -79,22 +79,20 @@ - (void)viewDidLoad
[locationManager startUpdatingHeading];
AppDelegate *appDeligate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
-
self.offer = [appDeligate getOfferDataById:self.offerId];
NSLog(@"Title:%@",self.offer.offer_title);
NSLog(@"Category:%@",self.offer.category);
NSLog(@"Lead Text:%@",offer.lead_text);
NSLog(@"Copy Text:%@",offer.copy_text);
-
NSLog(@"DetailView Offer:%@",self.offerId);
lblCategoryName.text = self.offer.category;
lblOfferTitle.text=self.offer.offer_title;
- scroll.contentSize = CGSizeMake(320, 1045);
+ scroll.contentSize = CGSizeMake(320, 670);
+ [[self.webFreeText.subviews objectAtIndex:0] setScrollEnabled:NO];
self.webFreeText.backgroundColor =[UIColor clearColor];
[self.webFreeText setOpaque:NO];
- NSString *weViewData =[NSString stringWithFormat:@"<HTML><body style=\"background-color:transparent\"><table><tr><td>%@<hr></td></tr><tr><td>%@</td></tr><tr><td>%@</td></tr></table></HTML>",offer.lead_text,offer.copy_text,offer.free_text];
- [self.webFreeText loadHTMLString:weViewData baseURL:nil];
-
+ [self loadWebView];
+ [self.webFreeText setDelegate:self];
ShopList *merchant = [appDeligate getStoreDataById:offer.store_id];
Categories *categoryData = (Categories *)[appDeligate getCategoryDataById:merchant.sub_category];
@@ -172,20 +170,11 @@ - (void)viewDidLoad
double Latitude = [merchant.latitude doubleValue];
double Longitude = [merchant.longitude doubleValue];
-
-
-
self.storeLocation = [[CLLocation alloc]initWithLatitude:Latitude longitude:Longitude];
-
-
CLLocationDistance meters = [self.currentLocation distanceFromLocation:self.storeLocation];
- //4000 mtr = 15 min
- //NSLog(@"meters %d",meters);
double me =[[NSString stringWithFormat:@"%.f",meters] doubleValue];
int time = (me/4000)*15;
self.lblDistanceLabel.text =[NSString stringWithFormat:@" %.fm (徒歩%d分)",meters,time];
-
-
if (merchant.is_child == 0) {
lblIsChild.hidden = YES;
@@ -205,7 +194,16 @@ -(void)viewWillAppear:(BOOL)animated
{
}
+- (void)webViewDidFinishLoad:(UIWebView *)webView
+{
+ mWebViewFlexibleHeight=[[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"] floatValue];
+
+}
+- (void) loadWebView {
+ NSString *weViewData =[NSString stringWithFormat:@"<HTML><body style=\"background-color:transparent\"><table><tr><td>%@<hr></td></tr><tr><td>%@</td></tr><tr><td>%@</td></tr></table></HTML>",offer.lead_text,offer.copy_text,offer.free_text];
+ [self.webFreeText loadHTMLString:weViewData baseURL:nil];
+}
- (void)viewDidUnload
{
[super viewDidUnload];
@@ -216,15 +214,18 @@ - (void)viewDidUnload
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
+ [self loadWebView];
return YES;
}
-(IBAction)btnOfferDetailsOpenClose:(id)sender
{
UIButton *btn = sender;
if(btn.tag ==0)
{
+ NSLog(@"WebviewHeifgt%lf",self.webFreeText.frame.size.height);
CGRect rec = self.viewOfferDetails.frame;
- rec.size.height = 500;
+ rec.size.height = mWebViewFlexibleHeight+50;
+ scroll.contentSize = CGSizeMake(320, scroll.contentSize.height+mWebViewFlexibleHeight-50);
self.viewOfferDetails.frame = rec;
[self.scroll scrollRectToVisible:self.viewOfferDetails.frame animated:YES];
CGRect rec1 = self.bottomView.frame;
@@ -236,12 +237,12 @@ -(IBAction)btnOfferDetailsOpenClose:(id)sender
{
CGRect rec = self.viewOfferDetails.frame;
rec.size.height = 115;
+ scroll.contentSize = CGSizeMake(320, 670);
self.viewOfferDetails.frame = rec;
[self.scroll scrollRectToVisible:self.viewOfferDetails.frame animated:YES];
CGRect rec1 = self.bottomView.frame;
rec1.origin.y = rec.origin.y + rec.size.height+20;
self.bottomView.frame = rec1;
-
btn.tag=0;
[self.arrowImage setImage:[UIImage imageNamed:@"Arrowwhite.png"]];
}
@@ -298,16 +299,15 @@ - (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(
[cell addSubview:lblAddress];
UILabel *lblAddressdetails = [[UILabel alloc]init];
- lblAddressdetails.frame = CGRectMake(150,0,150, 40);
- lblAddressdetails.textAlignment = UITextAlignmentCenter;
+ lblAddressdetails.frame = CGRectMake(160,0,150, 50);
+ lblAddressdetails.textAlignment = UITextAlignmentLeft;
lblAddressdetails.lineBreakMode = UILineBreakModeWordWrap;
lblAddressdetails.numberOfLines = 3;
lblAddressdetails.font = [UIFont systemFontOfSize:12];
lblAddressdetails.backgroundColor = [UIColor clearColor];
lblAddressdetails.textColor = [UIColor blackColor];
lblAddressdetails.text = merchant.address;
-
[cell addSubview:lblAddressdetails];
@@ -319,53 +319,45 @@ - (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(
UILabel *lblphone = [[UILabel alloc]init];
lblphone.frame = CGRectMake(0,0,150, 40);
lblphone.textAlignment = UITextAlignmentLeft;
-
-
lblphone.font = [UIFont systemFontOfSize:12];
-
lblphone.backgroundColor = [UIColor clearColor];
lblphone.textColor = [UIColor blackColor];
lblphone.text = @"電話番号";
[cell addSubview:lblphone];
UILabel *lblphonedetails = [[UILabel alloc]init];
- lblphonedetails.frame = CGRectMake(150,0,150, 40);
- lblphonedetails.textAlignment = UITextAlignmentCenter;
+ lblphonedetails.frame = CGRectMake(160,0,150, 50);
+ lblphonedetails.textAlignment = UITextAlignmentLeft;
lblphonedetails.lineBreakMode = UILineBreakModeWordWrap;
lblphonedetails.numberOfLines = 3;
lblphonedetails.font = [UIFont systemFontOfSize:12];
lblphonedetails.backgroundColor = [UIColor clearColor];
lblphonedetails.textColor = [UIColor blackColor];
lblphonedetails.text = merchant.phone;
-
[cell addSubview:lblphonedetails];
-
-
-
+ UIButton * btnPhoneNumber= [UIButton buttonWithType:UIButtonTypeCustom];
+ [btnPhoneNumber addTarget:self action:@selector(clickPhoneNumber:) forControlEvents:UIControlEventTouchUpInside];
+ btnPhoneNumber.frame=CGRectMake(160,0,150, 50);
+ [cell addSubview:btnPhoneNumber];
}
if (indexPath.row==2) {
-
-
+
UILabel *lbltime = [[UILabel alloc]init];
lbltime.frame = CGRectMake(0,0,150, 40);
lbltime.textAlignment = UITextAlignmentLeft;
-
-
lbltime.font = [UIFont systemFontOfSize:12];
-
lbltime.backgroundColor = [UIColor clearColor];
lbltime.textColor = [UIColor blackColor];
lbltime.text = @"営業時間";
-
[cell addSubview:lbltime];
UILabel *lbltimedetails = [[UILabel alloc]init];
- lbltimedetails.frame = CGRectMake(150,0,150, 40);
- lbltimedetails.textAlignment = UITextAlignmentCenter;
+ lbltimedetails.frame = CGRectMake(160,0,150, 50);
+ lbltimedetails.textAlignment = UITextAlignmentLeft;
lbltimedetails.lineBreakMode = UILineBreakModeWordWrap;
lbltimedetails.numberOfLines = 3;
@@ -397,8 +389,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(
[cell addSubview:lblholiday];
UILabel *lblholidaydetails = [[UILabel alloc]init];
- lblholidaydetails.frame = CGRectMake(150,0,150, 40);
- lblholidaydetails.textAlignment = UITextAlignmentCenter;
+ lblholidaydetails.frame = CGRectMake(160,0,150, 50);
+ lblholidaydetails.textAlignment = UITextAlignmentLeft;
lblholidaydetails.lineBreakMode = UILineBreakModeWordWrap;
lblholidaydetails.numberOfLines = 3;
@@ -431,7 +423,6 @@ - (void)locationManager:(CLLocationManager *)manager
{
self.currentLocation=newLocation;
-
CLLocationDistance meters = [self.currentLocation distanceFromLocation:self.storeLocation];
//4000 mtr = 15 min
//NSLog(@"meters %d",meters);
@@ -528,8 +519,10 @@ -(IBAction)btnBookmark:(id)sender
- (IBAction)getDirectionButtonPressed:(id)sender {
MapWithRoutesViewController *directionVC=[[MapWithRoutesViewController alloc] initWithNibName:@"MapWithRoutesViewController" bundle:nil];
- //directionVC setLat:lat setLong:lon];
- directionVC.destination=self.storeLocation;
+ AppDelegate *appDeligate =(AppDelegate *) [[UIApplication sharedApplication]delegate];
+ ShopList *merchant = [appDeligate getStoreDataById:self.offer.store_id];
+ directionVC.destination=self.storeLocation;
+ directionVC.destinationAddress=merchant.address;
[self presentModalViewController:directionVC animated:YES];
}
@@ -587,4 +580,11 @@ -(NSString *)shareKitMessage {
return strMessage;
}
+- (void)clickPhoneNumber:(id) sender {
+ AppDelegate *appDeligate =(AppDelegate *) [[UIApplication sharedApplication]delegate];
+ ShopList *merchant = [appDeligate getStoreDataById:offer.store_id];
+ NSString *phoneNumber = [@"tel://" stringByAppendingString:merchant.phone];
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
+}
+
@end
Oops, something went wrong.

0 comments on commit a0491a7

Please sign in to comment.