rss
twitter
  •  

Creating a mini map using MapKit on the iPhone

| Posted in iPhone |

1

So as promised here is the final part of my MapKit tips and tricks using the iPhone SDK.

Sorry it’s a little later than I intended as I wanted my version of the feature live in the AppStore before I published the article.

So we’ve seen before how to create a simple map, well now let’s see how to create a really small thumbnail sized version like this (sorry there is no anti-aliasing, the iPhone simulator doesn’t support it on MapKit, works fine on the actual device though!)

smallmap

In my version, I take this code and add it to a much larger view controller like this

bigmap

A bit of shameless plugging: this comes from Tweetings for the iPhone

I won’t cover anything more to this other than getting the map to a state where you can add it to any view of yours using the [object addSubview:mapView] call.

Generating the map

This is the same as generating a large map, that we’ve covered before, except the frame will be of a different size, however the most important factor here is we are going to scale the map

float scaleBy = 0.80;
MKMapView *mapView = [[[MKMapView alloc] initWithFrame:CGRectMake(-5, 0, 100/ scaleBy, 50/scaleBy)] autorelease];
mapView.delegate=self;
mapView.layer.cornerRadius = 10.0; // Make the corners rounded
mapView.opaque = NO; // If you are using in a UITableView never set to YES!
mapView.scrollEnabled = NO; // Don't allow user interaction
mapView.zoomEnabled = NO;
mapView.layer.borderColor = [UIColor colorWithWhite:0.0f alpha:0.5f].CGColor;
mapView.layer.borderWidth = 1.0f/ scaleBy;
mapView.layer.transform = CATransform3DMakeScale(scaleBy, scaleBy, 1.0);

At this point you can actually now add it to your view and set any other properties in the same way as you would normally, job done…. yes it really is that simple!

My take on Chrome OS

| Posted in Computers & Internet |

0

So Google have unveiled Chrome OS… which in actual fact is just a web browser where all you can do is interact with web apps. This isn’t a review, in fact if you want that go to Engadget

It’s even less than a thin client of old (read: Citrix). When did we suddenly decide that thin clients were a good idea again?

I’ll just put one single thought and it was said by Marc Andreessen in 1995

“[Netscape will soon reduce Windows to] a poorly debugged set of device drivers.”

Yeah that went well didn’t it.

FreeAgent: online accounting application

| Posted in Computers & Internet |

0

I like many people dread the 31st of January in the UK as it’s time to make sure I’ve not only submitted my tax return to HMRC but I’ve also paid any tax I owe.

It’s a horrible task but it’s just been made a whole lot easier using a great online application called FreeAgent.

For me it allows me to keep any invoices in check, remittance notes and all my expenses (including uploading a scanned PDF copy of the actual receipt).

Then come Self-Assessment time I can see my expenses all in one place and how much I can be expected to pay for my taxes.  It’s so easy it’s a dream, I can’t recommend it highly enough!

What’s more if you click through for a 30 day free trial from this link now, you’ll get a 10% discount!

FreeAgent sign-up

Now I’ll say upfront I don’t have much experience with this sort of application and I’ve never used Sage, etc . When you sign up for FreeAgent you get your own URL (http://yourcompany.freeagentcentral.com) and login, but this has one of the easiest to use interfaces I’ve seen for something that is a very complex and powerful web application.

In a matter of an hour I had all my yearly expenses in the system and added my income and even my PAYE P60 for my Self-Assessment.

I’ve only touched a handful of the features on offer, it also allows bank account integration which I’m sure is incredibly powerful, I’ve just not used it yet!

The Features (shamelessly copied from the FreeAgent website)
FreeAgent Features

  • Manage Projects & Time
    Manage your projects and contacts, track the time you spend and create flexible timesheet reports.
  • Simple, Powerful Invoicing
    Create great looking invoices with no fuss. Email them to the client and easily track through to payment.
  • Keep track of Expenses
    Keep tabs on your business and out-of-pocket expenses and quickly rebill to clients.
  • Superior Online Banking
    Online banking that’s better than the banks. Compare accounts and track balances.
  • Realtime Accounts
    No complicated procedures, FreeAgent simply works out your accounts as you run your business.
  • Unrivalled Tax Features
    Our unique Tax timeline lets you see important UK income, VAT and corporate tax dates and how much is due.

How to add a pin to embedded map

| Posted in iPhone |

2

Part one of this section on MapKits showed how to embed a map and place a floating toolbar for switching the map views, however it didn’t cover how to drop the pin where you wanted it.
MKMapKit

Create the Object

First lets create a new NSObject for the place mark. Let’s call it ‘PlaceMark’

PlaceMark.h

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

@interface PlaceMark : NSObject {
	CLLocationCoordinate2D coordinate;
	NSString *subtitletext;
	NSString *titletext;
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (readwrite, retain) NSString *titletext;
@property (readwrite, retain) NSString *subtitletext;
-(id)initWithCoordinate:(CLLocationCoordinate2D) coordinate;
- (NSString *)subtitle;
- (NSString *)title;
-(void)setTitle:(NSString*)strTitle;
-(void)setSubTitle:(NSString*)strSubTitle;

@end

PlaceMark.m

#import "PlaceMark.h"

@implementation PlaceMark
@synthesize coordinate, titletext, subtitletext;

- (NSString *)subtitle{
	return subtitletext;
}
- (NSString *)title{
	return titletext;
}

-(void)setTitle:(NSString*)strTitle {
	self.titletext = strTitle;
}

-(void)setSubTitle:(NSString*)strSubTitle {
	self.subtitletext = strSubTitle;
}

-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
	coordinate=c;
	return self;
}
@end

Adding a pin to your map

Firstly remember to add

#import "PlaceMark.h"

To your map controller, from the previous example inside the displayMap function under the region.center call

PlaceMark *addAnnotation = [[[PlaceMark alloc] initWithCoordinate:location] retain];
[addAnnotation setTitle:@"The Pin Title"];
[addAnnotation setSubTitle:@"The pin subtitle goes here"];

[mapView addAnnotation:addAnnotation];

Then create the following delegate method

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MyPin"];
    annView.animatesDrop=TRUE;
    annView.canShowCallout = YES;
	[annView setSelected:YES];
	annView.pinColor = MKPinAnnotationColorPurple;
    annView.calloutOffset = CGPointMake(-5, 5);
    return annView;
}

Voila you now have a pin dropped on the map and automatically selected. If you don’t want the title automatically displayed then change

[annView setSelected:YES];

The final part demonstrates how to create a mini map

How to embed a map on the iPhone

| Posted in iPhone |

1

In the first of a few posts I intend to make I’ll demonstrate some examples using the iPhone SDK.

This example will demonstrate how to embed a map, using the MKMapKit framework inside a UIView using the iPhone SDK. Note you must be using iPhone OS 3.0 or higher for this to work. The ultimate aim is to get a UIView that looks similar to this.

For this example I will assume you are already familiar with navigation and UIViews in the SDK (and so I won’t cover how to get the navigation bar at the top of this screenshot)

MKMapKit

Add the framework

First up you must go to the Frameworks folder of your XCode project and add the existing framework of MKMapKit.

Then inside the header file for your view add

#import <MapKit/MapKit.h>

Adding MapKit references to the header

Now we must add the mapKit instance to the header as well as the MapKit delegate

@interface MapKitViewController : UIViewController <MKMapViewDelegate> {
	MKMapView *mapView;
}
-(void)displayMap;

Initialize the Map

- (void)viewDidLoad {
	mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
	mapView.delegate=self;

	[self.view addSubview:mapView];
	[NSThread detachNewThreadSelector:@selector(displayMap) toTarget:self withObject:nil];
}

-(void)displayMap {
	MKCoordinateRegion region;
	MKCoordinateSpan span;
	span.latitudeDelta=0.2;
	span.longitudeDelta=0.2;

	CLLocationCoordinate2D location;
	location.latitude = -35;
	location.longitude = 146.2381;
	region.span=span;
	region.center=location;

	[mapView setRegion:region animated:TRUE];
	[mapView regionThatFits:region];
}

- (void)dealloc {
	[mapView release];
        [super dealloc];
}

This will give us a map fitting the screen with the region and zoom level set to best fit the coordinates given. Note that I have physically defined the coordinates here in this example, you can use something like the Google GeoCode API to convert addresses, etc to coordinates. I won’t cover that here.

Changing the map type

In the example above is a tool bar allowing you to switch map types

Let’s define the toolbar in the header file inside the @implementation

UISegmentedControl *buttonBarSegmentedControl;

Now inside the main code inside ViewDidLoad we add

buttonBarSegmentedControl = [[UISegmentedControl alloc] initWithItems:
	[NSArray arrayWithObjects:@"Standard", @"Satellite", @"Hybrid", nil]];
	[buttonBarSegmentedControl setFrame:CGRectMake(30, 10, 280-30, 30)];
        buttonBarSegmentedControl.selectedSegmentIndex = 0.0;	// start by showing the normal picker
	[buttonBarSegmentedControl addTarget:self action:@selector(toggleToolBarChange:) forControlEvents:UIControlEventValueChanged];
	buttonBarSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
	buttonBarSegmentedControl.backgroundColor = [UIColor clearColor];
	[buttonBarSegmentedControl setAlpha:0.8];

	[self.view addSubview:buttonBarSegmentedControl];

Then we must add the function for what happens when we tap on the tool bar

- (void)toggleToolBarChange:(id)sender
{
	UISegmentedControl *segControl = sender;

	switch (segControl.selectedSegmentIndex)
	{
		case 0:	// Map
		{
			[mapView setMapType:MKMapTypeStandard];
			break;
		}
		case 1: // Satellite
		{
			[mapView setMapType:MKMapTypeSatellite];
			break;
		}
		case 2: // Hybrid
		{
			[mapView setMapType:MKMapTypeHybrid];
			break;
		}
	}
}

In the next example, I’ll cover how to add the annotations (the small pins) to the map

The nasty side of Twitter

| Posted in Computers & Internet |

0

For most Twitter is a fantastic communication tool.  The way in which any one can follow anyone else and follow their stream of Tweets is exactly what makes Twitter the success that it is.  Unfortunately this level of openness is not without it’s pit falls.

I’ve been following @KirstieMAllsopp for a while now, in case you don’t know who Kirstie is she is British TV presenter and property guru.  After reading a few of her messages, it became clear that Kirstie and other famous celebrity tweeters are the victims of an Internet bullying campaign.

The bullies themselves don’t see that their words are bullying but by the very definition of what cyber bullying is, they are.  Now I won’t link to any of their accounts here because it’ll just give them some sick perversion and draw attention to them directly.

However Kirstie was unable to block them at the time from the mobile website of Twitter and had to wait until she could, consequently a number of people replied to Kirstie offering kind words of support only to have the bullies turn on them and flood their @mentions feed with abuse.

I too have had these messages sent to me and I’ll post a few examples now (self censored so as not to offend)

@KirstieMAllsopp f***** block me will ya ya fat do goody scrubber. Yer programme is s*** and ur fat nd ugly lol

@twbrit u think u r so f****** clever e mailing that fat bird off telly well keep ur f***** thoughts to yerself bout my mates or Ill ave u

@richardhyland if u bad mouth @****** or @********* gin u 4 eyed gimp Ill f****** kick ur chav arse this will be ur only warning c***

And that was just three of around 30 tweets from one of these users in around 30 minutes!

Others included

@KirstieMAllsopp fat s*** (via @******) this one is trying to ban you all @****** She is a seriously obese dull bitch

@KirstieMAllsopp kirstie, where on your body is the perfect location for me to s***? your chest? your hair? your eyes?

I think any sane person will agree it’s pretty foul stuff and whilst most adults swear at some point, there is simply no excuse or point in their sad little tweets apart from upsetting normal people using a great service like Twitter.

Twitter do provide a method of feedback to harassment, yet a week after this came to my attention, every single one of the accounts is still active.  Is Twitter unable or unwilling to do something about it?

Celebrities have often had to put up with a lot because of their fame, paparazzi, untrue stories, but no one deserves to be abused or bullied in this way whether it be online or in person.

Update: Since I posted this, one of the accounts has now gone, I don’t think it was suspended but the user either deleted it or changed his screen name

Update II: Two down now… hopefully more to come

Apple Store Love Song

| Posted in Computers & Internet |

0

Simply genius

The iTunes App Store review process

| Posted in iPhone |

0

Being a small fry iPhone app developer, that being I do so in my own spare time because I like developing apps for the iPhone, I’ve simply got to comment about the App Store review process as it stands.

I won’t make any individual comments about my personal rejections I’ve had except to say. I have had a number of rejections.

One update got rejected numerous times because apparently if you use a UIWebView where the user might be able to get to Google and therefore access pictures of <shock>naked people</shock> then you have to rate your App as 17+.  Let us ignore the fact that they could just close your app and go to mobile Safari shall we, it would be by far easier?

Another one I reason I’ve been rejected for features not doing something Apple think they should, yet that very same feature was actually in the version before it…. still on sale in the App Store.  Inconsistent reviewing doesn’t even begin to cover it!

So this leads me on to a blog post I read today from Joe Hewitt.  For anyone who doesn’t know who Joe is, he is the guy who wrote the amazing Facebook app for the iPhone.

I have only one major complaint with the App Store, and I can state it quite simply: the review process needs to be eliminated completely.

Does that sound scary to you, imagining a world in which any developer can just publish an app to your little touch screen computer without Apple’s saintly reviewers scrubbing it of all evil first? Well, it shouldn’t, because there is this thing called the World Wide Web which already works that way, and it has served millions and millions of people quite well for a long time now.

Go and read his excellent post now at what I totally agree with…. especially as I have one app that I originally submitted a month ago, awaiting approval!

Just quit your moaning Opera

| Posted in Computers & Internet |

0

So I’ve been following the developments of Opera vs Microsoft vs the EU browser war and as far as I understand it this is what’s happened so far

1) The EU has been concerned for sometime that Microsoft has bundled Internet Explorer and wants it removed as a default installation

2) Opera has complained to the EU as well

3) Microsoft has developed a special version of Windows 7 just for the EU which doesn’t have Internet Explorer installed

Now could someone just explain to me for a minute, if the web browser is not installed by default, how the hell are you supposed to get a web browser running without installing IE from the Windows Disk. I don’t know about you but I don’t tend to keep a resource of Web browser installers lying around.

Next comes that, did anyone bother to ask users what they wanted? I didn’t get asked and I don’t really mind IE being installed… I’m not forced to use it and I don’t have to use it if I don’t want to. It’s not like Microsoft prevent you from installing other browsers.

Now I read this morning over at The Register that Microsoft have proposed a browser ballot screen when you install Windows asking you to pick which browser you want installed.  Apparently this is the mock up they provided.

microsoft_proposed_ballot_screen

To be honest, that screen seems perfectly fine to me, it’s clean, it’s relatively straight forward and offers the most popular browsers around.  Now of course you can’t realisically expect Microsoft to put every web browser in existence on the screen either, there are far too many, so who decides who makes the grade?

However I read in that same article that Opera are not happy with that either

Lie has reportly said that the use of icons in the ballot screen could result in a natural bias towards IE. The sticking point could be that the IE logo has become synonymous with Windows.

“The blue ‘e’ has become so associated with the Internet in general, due to the bundling with Windows. We think using the blue ‘e’ might not be such a good idea,” told TechFlash.

My only response is ‘Opera just stop moaning’. Just because your browser is rubbish and no one wants to use it doesn’t mean that you have to go out of your way to make things harder for users.  Heck, the Google logo there is highly recognisable so I’d imagine quite a number of users will actually click on that instead of IE.

I’m sure Opera won’t be happy until the screen says do you want to install Opera or if you want to install another click on the little button, type in the URL to a .exe for some other browser… oh and IE is now renamed to ‘FE£RG245wvf”%s TGE£%”V’

Indeed which Opera might have a higher Acid 3 rating than Internet Explorer I’d still rate IE8 above Opera in terms of a better product.   If I’d move the logos around in my personal preference I’d only move Internet Explorer and slot it in nicely between Google Chrome and Opera.

However when the next version of Windows comes out I don’t want to buy a cripled version from the EU, I’ll try to find a legal way of getting the US version thank you very much… much like the unused N versions without media player.