add offsetTop option to mapkit plugin, remove the atBottom option

This commit is contained in:
Max Ogden
2011-07-08 20:32:17 -07:00
committed by shazron
parent 933f7f1a28
commit 2cd1ba1307
3 changed files with 18 additions and 38 deletions

View File

@@ -66,7 +66,7 @@
buttonCallback: "cbMapCallback",
height:360,
diameter:1000,
atBottom:true,
offsetTop:25,
lat:pin.lat,
lon:pin.lon
};
@@ -104,7 +104,7 @@
buttonCallback: "cbMapCallback",
height:260,
diameter:1000,
atBottom:true,
offsetTop:25,
lat:pin.lat,
lon:pin.lon
};

View File

@@ -6,17 +6,10 @@
#import "MapKit.h"
#import "PGAnnotation.h"
#import <PhoneGap/SBJsonParser.h>
#import <PhoneGap/SBJSON.h>
#import "AsyncImageView.h"
#ifdef PHONEGAP_FRAMEWORK
#import <PhoneGap/SBJsonParser.h>
#import <PhoneGap/SBJSON.h>
#else
#import "SBJsonParser.h"
#import "SBJSON.h"
#endif
@implementation MapKitView
@synthesize buttonCallback;
@@ -25,7 +18,7 @@
@synthesize imageButton;
-(PGPlugin*) initWithWebView:(UIWebView*)theWebView
-(PhoneGapCommand*) initWithWebView:(UIWebView*)theWebView
{
self = (MapKitView*)[super initWithWebView:theWebView];
return self;
@@ -93,18 +86,17 @@
[mapView removeAnnotations:mapView.annotations];
}
// default height
// defaults
CGFloat height = 480.0f;
// default at bottom
BOOL atBottom = YES;
CGFloat offsetTop = 0.0f;
if ([options objectForKey:@"height"])
{
height=[[options objectForKey:@"height"] floatValue];
}
if ([options objectForKey:@"atBottom"])
if ([options objectForKey:@"offsetTop"])
{
atBottom=[[options objectForKey:@"position"] isEqualToString:@"bottom"];
offsetTop=[[options objectForKey:@"offsetTop"] floatValue];
}
if ([options objectForKey:@"buttonCallback"])
{
@@ -121,25 +113,13 @@
CGRect webViewBounds = self.webView.bounds;
CGRect mapBounds;
if (atBottom)
{
mapBounds = CGRectMake(
webViewBounds.origin.x,
webViewBounds.origin.y + webViewBounds.size.height - height,
webViewBounds.size.width,
height
);
}
else
{
mapBounds = CGRectMake(
webViewBounds.origin.x,
webViewBounds.origin.y,
webViewBounds.size.width,
webViewBounds.origin.y + height
);
}
mapBounds = CGRectMake(
webViewBounds.origin.x,
webViewBounds.origin.y + (offsetTop / 2),
webViewBounds.size.width,
webViewBounds.origin.y + height
);
[childView setFrame:mapBounds];
[mapView setFrame:mapBounds];

View File

@@ -13,7 +13,7 @@ function MapKitPlug()
"buttonCallback": "window.plugins.mapKit.onMapCallback",
"height":460,
"diameter":1000,
"atBottom":true,
"offsetTop":0,
// ( nitobi HQ, if you have issues, send missles here )
"lat":49.281468,
"lon":-123.104446
@@ -72,7 +72,7 @@ MapKitPlug.prototype.showMap = function()
buttonCallback:String, string callback function
height:Number, - pixels
diameter:Number, - meters
atBottom:Bool,
offsetTop:Number, - pixels
lat:Number,
lon:Number
};