iPhone Google Map API

iPhone Google Map API

The Map Kit framework provides an interface for embedding maps directly into your iPhone/iPad App. This framework also provides support for annotating the map , adding overlays, and performing reverse-geocoding lookups to determine placemark information for a given map coordinate. Google Map API is one framework that can be used in our App to make it Graphical . Using Google Webservices we can get Direction b/w two Places (if existing) and can draw that path on Map with their Distance/Time to cover that .


1) How to Render Map on iPhone/iPad
Map can be of number of Types
a) Standard Map View
[map_View setMapType:MKMapTypeStandard];
b) Hybrid Map View
[map_View setMapType:MKMapTypeHybrid];
c) Satelite Map View
[map_View setMapType:MKMapTypeSatelite];
I am going to create MapViewController Class for MapView

MapViewController.h file

@interface MapViewController : UIViewController{
MKMapView *Map_View;
UIImageView *routeView;
UIColor* lineColor;
}
@end

MapViewController.m file
#import "TaxiCompaniesMapViewController.h"
#import

@implementation TaxiCompaniesMapViewController
@synthesize Map_View;
@synthesize routeView;
@synthesize lineColor;

-(void)viewdidLoad{
Map_View = [[MKMapView alloc]initWithFrame:CGRectMake(0,40,320,460)];
[map_View setMapType:MKMapTypeStandard];
[map_View setZoomEnabled:YES];
[map_View setScrollEnabled:YES];
map_View.showsUserLocation = TRUE;
map_View.delegate = self;
MKCoordinateRegion region;
CLLocation *location = [[CLLocation alloc]initWithLatitude:26.94166
longitude:75.785065];
region.center = location.coordinate;
MKCoordinateSpan span;
span.latitudeDelta = 0.09;
span.longitudeDelta = 0.09;
region.span = span;
[Map_View setRegion:region animated:YES];
[Map_View regionThatFits:region];
[Map_View setShowsUserLocation:YES];
[self.view addsubView:map_View];


Points to Remember

1) These two files are used to Render Map on Map in My example
2) In this example , default I provided Jaipur location to be in Center , you can provide your desired location , that will be in Center.
3) I used span (zoom level ) to approximate of 2 miles , you can change it . mind that decreasing span level increases zoom level on Map and
    this span limits b/w 0 to 180.

0 comments:

Post a Comment