iPhone アプリケーション
-
はてな touch/Hatena touch
-
LDR touch
-
テレビ番組表/TV Listings
-
LCD Clock by forYou Inc.
-
MyWebClip by forYou Inc.
-
MyWebClip LITE by forYou Inc.
-
Japan Subway Route Map by Studio Heat
-
こころくろっく by AppBank
-
英辞郎 on the WEB for iPhone by アルク
-
i-Radio by i-Radio
-
くるりんぱ性格診断 by 小学館
-
英辞郎検索ランキング(アルク) by アルク
-
kotobank - コトバンク by genesix
-
miil by frogapps
iPad アプリケーション
共著
2009-08-12
MapKitでルート案内をするライブラリを公開しました。
MapKitフレームワーク単体では、標準のマップアプリのようなナビは作れないのですが、Google Maps APIと組み合わせることで、似たような機能を実現してみました。
kishikawakatsumi/MapKit-Route-Directions - GitHub
仕組みは、裏でJavascriptを実行して、Google Maps APIを叩いています。
結果としてルートの座標が緯度経度として返ってくるので、その値を使用して、MapViewの上にルートのラインを描画します。
Javascriptの実行エンジンにUIWebViewを使用します。
Google Maps APIのラッパーと、ラインをマップビューの上に描画する拡張から構成されています。
ラインの描画は下記の記事を参考にしました。
The Reluctant Blogger : Drawing polyines or routes on a MKMapView (Using Map Kit on the iPhone)
使い方は下記のような感じです。
UICGDirectionsやUICGDirectionsOptionsというクラスがGoogle Maps APIのラッパーです。
APIの実行、および結果の取得に使用します。
NSString *startPoint = [NSString stringWithUTF8String:"セルリアンタワー"] NSString *endPoint = [NSString stringWithUTF8String:"東京ディズニーランド"]; UICGDirections *diretions = [UICGDirections sharedDirections]; diretions.delegate = self; UICGDirectionsOptions *options = [[[UICGDirectionsOptions alloc] init] autorelease]; [diretions loadWithStartPoint:startPoint endPoint:endPoint options:options];
以下のデリゲート・メソッドを用意しています。
オブジェクトの初期化の終了時、および結果を取得するたびに呼ばれるメソッドです。
- (void)directionsDidFinishInitialize:(UICGDirections *)directions; - (void)directions:(UICGDirections *)directions didFailInitializeWithError:(NSError *)error; - (void)directionsDidUpdateDirections:(UICGDirections *)directions; - (void)directions:(UICGDirections *)directions didFailWithMessage:(NSString *)message;
マップビューに線を引くには次のようにします。
- (void)directionsDidUpdateDirections:(UICGDirections *)directions { // Overlay polylines UICGPolyline *polyline = [directions polyline]; NSArray *routePoints = [polyline routePoints]; routeOverlayView = [[UICRouteOverlayMapView alloc] initWithMapView:routeMapView]; [routeOverlayView setRoutes:routePoints];
UICGDirectionsオブジェクトからUICGPolylineオブジェクトを取得します。
UICGPolylineオブジェクトからルートの頂点座標を取り出し、UICRouteOverlayMapViewクラスに渡します。
UICRouteOverlayMapViewクラスが、マップビューの上に線を描画します。
ちょっと面白いところでは3箇所以上のルートを検索できます。
下の例は、「セルリアンタワー」「東京ドーム」「品川駅」「東京ディズニーランド」を経由するルートです。
まだ、作りかけですが、いろいろ遊べると思います。
よかったら、触ってみてください。
参考リンク
- 78 http://reader.livedoor.com/reader/
- 55 http://reader.livedoor.com/utility/iphone/
- 47 http://secure.ddo.jp/~kaku/tdiary/
- 47 http://www.google.co.jp/search?hl=ja&client=firefox-a&rls=org.mozilla:ja:official&q=centos+virtualbox+解像度&btnG=検索&lr=lang_ja
- 40 http://twitter.com/
- 29 http://www.google.co.jp/search?q=はてなtouch&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja-JP-mac:official&client=firefox-a
- 28 http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF-8&rlz=1T4HPNW_jaJP315JP315&q=はてなtouch
- 27 http://www.google.co.jp/reader/view/
- 23 http://www.google.com/reader/view/
- 20 http://d.hatena.ne.jp/moto_maka/20090220/1235073464


























