Mostly Harmless blog

Just another WordPress weblog

iOS 4 map kit framework overlays

Written on June 27, 2010 at 4:11 pm, by admin

Recently, i’ve been getting to grips with some of the new APIs in iOS 4. One of the more interesting additions is the ability to add overlays using mapkit.

Without further ado, here is some sample code.

First, create a new project, and make sure to link the MapKit and CoreLocation frameworks. Add a Xib to the project, and create the accompanying view controller .h & .m files.

Open the header file and create an IBOutlet for the map view, remembering to include the MapKit header file, and make sure it knows about the MKMapViewDelegate protocol.

 

#import <UIKit/UIKit.h>

#import <MapKit/MapKit.h>

 

@interface MH_mapOverlaySampleViewController : UIViewController<MKMapViewDelegate> {

MKMapView *mapView;

}

@property(nonatomic,retain)IBOutlet MKMapView *mapView;

@end



Open the xib file and add a map view, link this to the mapView outlet, and then set the mapView’s delegate to the view controller we created earlier.

 

Save and close the xib file, then open the view controller.m file.

First, we synthesize the map view outlet, then in the viewDidLoad method, we create a coordinate array, containing the coordinates for the overlay.

Next, create an MKPolyLine object, and pass it the coords array, and the number of items it contains.

Add the polyline object to the mapview object.

We need to implement one final method before anything will display, which is for the mapView:viewForOverlay: callback.

 

#import “MH_mapOverlaySampleViewController.h”

 

@implementation MH_mapOverlaySampleViewController

@synthesize mapView;

 

- (void)viewDidLoad {

[super viewDidLoad];

[[self mapView] setDelegate:self];

 

CLLocationCoordinate2D coords[5]={

CLLocationCoordinate2DMake(37.33444, -122.036777),

CLLocationCoordinate2DMake(37.337511, -122.036777),

CLLocationCoordinate2DMake(37.337511, -122.032228),

CLLocationCoordinate2DMake(37.33444, -122.032228),

CLLocationCoordinate2DMake(37.33444, -122.036777)

};

MKPolyline *polyLine=[MKPolyline polylineWithCoordinates:coords count:5];

[[self mapView] setCenterCoordinate:CLLocationCoordinate2DMake(37.336086,-122.03454)];

[[self mapView] addOverlay:polyLine];

MKCoordinateSpan span = MKCoordinateSpanMake(0.005, 0.005);

[[self mapView]setRegion:MKCoordinateRegionMake(CLLocationCoordinate2DMake(37.336086,-122.03454), span) animated:YES];

}

 

-(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id)overlay{

MKPolylineView *polyLineView = [[[MKPolylineView alloc] initWithOverlay: overlay] autorelease];

polyLineView.strokeColor = [UIColor redColor];

polyLineView.lineWidth = 5.0;

return polyLineView;

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

}

- (void)dealloc {

[super dealloc];

}

@end



 

VATMobile 1.0 has been released!

Written on April 3, 2010 at 1:43 am, by admin

The title says it all really.

vatmobileicon.png

So whats it for?
VATMobile is for easy VAT/TVA calculation on your iPhone OS device.

you can:

  • Calculate how much VAT/TVA was paid from a gross amount.
  • Calculate how much VAT/TVA was paid from a Net amount.
  • Calculate how much the Gross and Net amounts were, from the amount of VAT/TVA paid.
  • Use varying rates of VAT. the UK Standard and Reduced rates are preset, and there is also a slot for a custom rate. All rates can be adjusted.

How About A Picture…

vatmobileiphonelarge.png

New web design!

Written on February 19, 2010 at 8:16 pm, by matt

 

Here it is. not a massive change, but should load a bit quicker.

 

Shift Log 2.7 has been released!

Written on February 16, 2010 at 2:52 am, by admin

Shift Log 2.7 has been approved by apple, and is now on sale at http://www.itunes.com/apps/shiftlog

one of our most popular features has been showing the shift duration, and in the latest version of shift log, we will now total the weeks shifts and display it inline with the section headers!

Screen shot 2010-02-16 at 01.46.48.png

We have also given you the option of using a 12 hour, or 24 hour clock, we have split the duration out in the CSV export, so that you can now sort by shift durations, and use formulae on them, and we have added a running counter of the current shift duration to the front page!

Shift Log Summer Sale!

Written on July 2, 2009 at 11:42 pm, by admin

Shift log is on Sale until the end of July!
prices vary depending on your iTunes store:

  • $1.99 United States*
  • $20.00 Mexico
  • CA$1.99 Canada
  • £1.19 UK
  • 1,59 € European Union*
  • 11.00Kr(NO) Norway
  • 15.00Kr(SE) Sweden
  • 12.00Kr(DK) Denmark
  • 2.20Fr Switzerland
  • AU$2.49 Australia
  • NZ$2.59 New Zealand


*The U.S. price applies to all countries where applications are sold in U.S. dollars. The European Union price applies to all countries where applications are sold in Euros.

Shift Log 2.5 has been approved!

Written on June 28, 2009 at 12:06 am, by admin

So apple have cleared Shift Log v2.5 for the App Store!

This release adds some polish to the previous release. Shift Log will also now enable you to record additional information about each shift, including:

  • Job/task name
  • Job/ID number
  • A brief description of the job/task

Shift Log will now display a badge telling you if you have an unfinished shift running,
And last but not least, Shift Log will now display the duration of each shift,in hours and minutes, and also in decimal hours. This option can be changed in the settings application.

iPhone/iPod Touch 3.0

Written on June 18, 2009 at 10:24 am, by admin

Apple have finally released the 3.0 update, it’s mostly more of the same.
Apple have taken an already good system and added polish.
Some of the new features you will come across:

  • Landscape keyboard is now available in most applications
  • Spotlight search
  • New voice recording application.
  • MMS

whilst these new features are great, there are other features that will create a much better experience as time goes on;
New developer APIs:

  • Core Data – there is a fair chance that shiftlog will switch over to this in the coming months.
  • MapKit – which will allow developers to embed google maps into their application.
  • Push notifications – this will allow you to receive notifications from the internet, without having the application running – and will pave the way for real instant messaging clients…