Go for it!

モーターサイクルと自転車とキャンプの日々。

Garmin Communicator Plugin APIで遊ぶ

Garmin製品にはウェブブラウザ上のJavascriptを使ってGPSデータの読み書きが出来るGarmin Communicator Plugin APIというものがあります。

MotionBased.comなどで実現されているように、EDGE 705から直接ファイルアップロードなどが出来ると便利だなあと考えていたのでGarmin開発者向けサイトののworking exampleを見つつ軽く遊んでみました。

※わたしはjavascriptほとんど解りませんので、間違ったことが書いてあるかも知れません

まず、Garmin Communicator Pluginが入っていることをGarminのテストページで確認する。このプラグインはWindowsではIE6以降およびFirefox 1.5以降、MacではSafari 2以降およびFirefox 2以降で動作するので、テスト結果がNGだったらインストールしておきましょう

APIはJavascriptで実装されているので安定版のアーカイブをダウンロードしてローカルに保存するか、Garminのサイトから直接インクルードする。

Garminのデモページを抜粋して解説。まず、Javascriptをリンクする。GarminDeviceDisplayとprototypeの両方が必要なので必ずリンクすること。

[code lang=‘html’]

[/code]

Garminクラスが使えるようになるのでGarmin.DeviceDisplayクラスにオプションをくっつけてオブジェクトを生成する。

[code lang=‘javascript’]

[/code]

オプションはかなりたくさんあるのだが、公式のドキュメントのどこを見ればいいのかよく解らなかったので、ソースコードのコメントを読んだ…。

showReadDataElement: Display the user interface associated with reading from a connected device.

よくわからん。接続されたデバイス依存のUIを表示するということか?

showReadGoogleMap: Display Google map to show tracks and laps that have been read. When showReadDataElement is set to false, the Google map will not show

GoogleMapを表示するかどうか。利用するにはGoogleMaps API Keyが必要。

showProgressBar: The progress bar is a graphical percentage bar used to display the amount of reading/writing is complete.

デバイスからのアップロード時にプログレスバーを表示するかどうか。

showReadTracksSelect: Display the track select dropdown. When showReadDataElement is set to false, the select track dropdown will not show.

トラックデータのプルダウンメニューを表示するかどうか。

showReadWaypointsSelect: Display the waypoint select dropdown. When showReadDataElement is set to false, the select waypoint dropdown will not show.

ウェイポイントのプルダウンメニューを表示するかどうか。

showFindDevicesElement: When more than one device is detected automaticly pick the first device. This allows single button interfaces to avoid having to ask the user to choose the device and keeps the deviceSelect hidden.

デバイス選択のプルダウンを表示するかどうか。わたしの環境では、EDGE、EDGEに接続されたMicroSD、(何故か)iDiskが表示される。

autoFindDevices: Looks for devices as soon as the page is loaded and the plugin unlocked. This might be particularly annoying in many situations since the plugin requires the user to authorize access to device information via a dialog box.

デバイスを自動検出するかどうか。

実際の表示は次のようなHTMLを書くだけで簡単。

[code lang=‘html’]

[/code]

試してみたところ、EDGE内に大量のデータがあるとアップロードがものすごく遅い上に、XMLの解析に時間がかかるようでブラウザがクラッシュしかけてしまう。EDGE内のデータはコンパクトに保っておく必要がありそうだった。

アップロードされたデータがどうなっているかは今のところよく理解できていないが、javascriptのオブジェクトに記録されているのかなあ。もうちょっと調べてみる必要がありそう。

AD

【送料・代引手数料無料】Edge 705 心拍計、回転計付き

【送料・代引手数料無料】Edge 705チーム・ガーミンモデル【オレンジ×ブルー】心拍計、回転計付き

[ad#text_wide]