2011-08-14 12 views
1

http://navigationapps.com/wp-content/uploads/2010/10/point-inside-2.pngに似た建物ナビゲーションアプリケーションを作成しようとしています。私はUIImageViewとしてビルフロアプラン画像を表示し、CoreLocationを使用してピンポインタの経度と緯度座標を取得することを計画しています。次のステップは、私もイメージにポイントをプロットしていますか? - 私はすでにユーザーの緯度と経度の座標を取得することができます。iOS CoreLocation画像の上にユーザの位置をプロット

+0

@ spike Lee私は同じことをしたいと思う私はそれを開始するためのいくつかの初期ステップを教えてくれますか? –

答えて

3

まず、ピンポイントのアイコンを表示するためのUIImageView、次に緯度/経度の座標を上の位置に変換する関数あなたのイメージ

は、このメソッドから返さそれからちょうど値にあなたのピンUIImageView「センター」プロパティを設定し

- (CGPoint)plotPointOfLocation:(CLLocationCoordinate2D)location { 
    CLLocationCoordinate2D topLeftCoordinate = CLLocationCoordinate2DMake(/* the lat/long of the top-left of the plan image */); 
    CLLocationCoordinate2D bottomRightCoordinate = CLLocationCoordinate2DMake(/* the lat/long of the bottom-right of the plan image */); 
    CGSize planImageSize = CGSizeMake(/* the size of the plan image, as drawn on the screen, in pixels */); 

    CLLocationDegrees latSpan = bottomRightCoordinate.latitude - topLeftCoordinate.latitude; 
    CLLocationDegrees longSpan = bottomRightCoordinate.longitude - topLeftCoordinate.longitude; 

    CLLocationCoordinate2D offsetLocation = CLLocationCoordinate2DMake(location.latitude - topLeftCoordinate.latitude, 
                     location.longitude - topLeftCoordinate.longitude); 

    CGPoint ret = CGPointMake((offsetLocation.latitude/latSpan) * planImageSize.width, 
           (offsetLocation.longitude/longSpan) * planImageSize.height); 
    return ret; 
} 

、建物のフロアプランイメージが先頭に北と整列していると仮定します。

+0

あなたのおかげで助けてくれてありがとう、また私にプロセスの位置合わせを教えてくれる?どの解像度/サイズにする必要がありますか? –

+0

あなたが好きなサイズや解像度にすることができますが、画面に表示されるサイズは 'planImageSize'に入力する必要があります。返される点はイメージの左上からの相対値なので、イメージビューがスーパービューの0,0にない場合は、これをオフセットする必要があります。 – joerick

+0

今すぐ試していただきありがとうございます –