ラベル Picasa の投稿を表示しています。 すべての投稿を表示
ラベル Picasa の投稿を表示しています。 すべての投稿を表示

2009年10月11日日曜日

OpenLayers で東京都の地図表示 10d Google Pisca で位置情報のある写真を表示4

ポップアップ表示をするため、KML Layer Example(sundials.html)を参考に次のコードを追加します。
前述のコードは削除してください。

---
var sundials = new OpenLayers.Layer.Vector("西立川駅", {
projection: map.displayProjection,
strategies: [new OpenLayers.Strategy.Fixed()], //一度だけ feature を要求
protocol: new OpenLayers.Protocol.HTTP({ //ベクトルレイヤのための基本的な HTTP プロトコル
url: "西立川駅.kml",
format: new OpenLayers.Format.KML({
extractStyles: true, //スタイルの週出
extractAttributes: true //属性の抽出
})
})
});

map.addLayer(sundials);

select = new OpenLayers.Control.SelectFeature(sundials);

sundials.events.on({
"featureselected": onFeatureSelect, // ポップアップ表示時のPointの色
"featureunselected": onFeatureUnselect // ポップアップを閉じたとき元に戻す
});

map.addControl(select);
select.activate();

map.addControl(new OpenLayers.Control.LayerSwitcher());
---
function onPopupClose(evt) {
select.unselectAll();
}
function onFeatureSelect(event) {
var feature = event.feature;
// Since KML is user-generated, do naive protection against
// Javascript.
var content = "<h2>"+feature.attributes.firstChild.name + "</h2>" + feature.attributes.description; // Placemark の子要素 name と description の表示
if (content.search("<script") != -1) {
content = "Content contained Javascript! Escaped content below.<br />" + content.replace(/</g, "<");
}
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(100,100),
content,
null, true, onPopupClose);
feature.popup = popup;
map.addPopup(popup);
}
function onFeatureUnselect(event) {
var feature = event.feature;
if(feature.popup) {
map.removePopup(feature.popup);
feature.popup.destroy();
delete feature.popup;
}
}

</script>
---

2009年10月10日土曜日

OpenLayers で東京都の地図表示 10c Google Pisca で位置情報のある写真を表示3

KML ファイルを Eclipse にインポートして OpenLayers で表示します。

1 Eclipse のメニューバーの ファイル->インポートをクリックします。
2 「選択」ダイアログで「ファイルシステムをクリックして「次へ」ボタンをクリックします。
3 「次のディレクトリーから」右側の「参照」ボタンクリックします。
4 KML ファイルがあるフォルダをクリックして「OK」ボタンをクリックします。
5 「ファイル・システム」ダイアログで KML ファイルをチェックして「宛先」を確認し、「完了」ボタンをクリックします。
6 画像も同じようにインポートします。

Eclipse で KML ファイルを開くときは、ファイルを右クリックして アプリケーションから開く->テキストエディタ をクリックします。
画像(NEC_0036.JPG)の位置を修正します。

---
<img src="NEC_0036.JPG">
---

tokyo_bmi_pgis_img03.html に次のコードを追加します。

---
// ここから追加
map.addLayer(new OpenLayers.Layer.GML("西立川駅", "西立川駅.kml",
{
format: OpenLayers.Format.KML,
formatOptions: {
extractStyles: true,
extractAttributes: true
}
}));
// ここまで

map.addControl(new OpenLayers.Control.LayerSwitcher());
---



このレイヤを表示すると、前回設定した GeoRSS で表示したマーカをクリックしてもポップアップ表示しません。
レイヤスイッチャーでどちらかだけ表示してください。

2009年10月8日木曜日

OpenLayers で東京都の地図表示 10b Google Pisca で位置情報のある写真を表示2

Google Earth から KML ファイルの出力

私の debian では Google Earth が起動できなかったので、ここからの操作は Mac で操作しました。
iPhoto に KMZ ファイルを出力するプラグインをインストールして KMZ ファイルを出力し、Google Earth で表示しました。
文字化けしたので修正しました。
(Linux 版には、tool -> Geotag -> View in Google Earth... がありますが動作するか確かめられませんでした。
Windows 版の Picasa には「ジオタグ」ボタンがあり、Google Earth に表示できます。)

KMZ ファイルを Google Earth で表示すると、「保留」にフォルダが作成されます。
そのフォルダを右クリックして「名前をつけて場所を保存」をクリックします。
「フォーマット」を「kml」にして「保存」ボタンをクリックします。




フォルダ(西立川駅)と画像(NEC_0036)の KML は次の様になりました。

西立川駅.kml の内容

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Folder creator="iPhotoToGoogleEarth http://craig.stanton.net.nz">
<name>西立川駅</name>
<open>1</open>
<description>JR青梅線</description>
<Placemark>
<name>NEC_0036.JPG</name>
<snippet></snippet>
<Snippet maxLines="0"></Snippet>
<description><![CDATA[<center><img src="西立川駅.kmz/images/NEC_0036.JPG"><br></center>]]></description>
<Point>
<coordinates>139.393723,35.703873,0</coordinates>
</Point>
</Placemark>
</Folder>
</kml>

NEC_0036.kml の内容

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Placemark>
<name>NEC_0036.JPG</name>
<snippet></snippet>
<Snippet maxLines="0"></Snippet>
<description><![CDATA[<center><img src="西立川駅.kmz/images/NEC_0036.JPG"><br></center>]]></description>
<Point>
<coordinates>139.393723,35.703873,0</coordinates>
</Point>
</Placemark>
</kml>

2009年10月7日水曜日

OpenLayers で東京都の地図表示 10a Google Pisca で位置情報のある写真を表示1

携帯などで写した位置情報のある写真を Google Pisca -> Google Earth -> KML ファイル出力という手順で表示します。
今回は、Picasa3 と Google Earth をインストールをします。

Picasa3 のインストール
1「Picasa ウェブ アルバム」のページの「Picasa 3 のダウンロード」リンクをクリックします。
2 「Picasa for Linux」ページの「Download Picasa 3 for Linux (beta)」ボタンをクリックします。
3 「Picasa 3.0 for Linux (beta)」ページの「●deb, for Debian/Ubuntu i386:
http://dl.google.com/linux/deb/pool/non-free/p/picasa/picasa_3.0-current_i386.deb」リンクをクリックします。
4 「picasa_3.0-current_i386.deb を開く」で「ファイルを保存」をクリックします。
5 root で次の様に実行します。
user@debian:~/Desktop# dpkg -i picasa_3.0-current_i386.deb

Picasa の起動
Debian では、アプリケーション -> その他 -> Picasa で起動します。
Debian を再起動したら、アプリケーション -> グラフィックス -> Picasa -> Picasa で起動するようになってました。
使用承諾で I Agree ボタンをクリックすると起動して、Debian 内の画像検索を始めます。

Picasa のフォント
文字化けしているところがあるので、検索してみるとみなさんが対処法を載せていました。
私もみなさんのお力をお借りしました。

1 次の様にリンクを作成。

debian:/home/user# ln -s /usr/share/fonts/truetype/ /opt/google/picasa/3.0/wine/drive_c/windows/fonts
debian:/home/user# ls -l /opt/google/picasa/3.0/wine/drive_c/windows/fonts/
---
lrwxrwxrwx 1 root root 26 2009-09-29 19:18 truetype -> /usr/share/fonts/truetype/
---

2 system.reg を編集。

user@debian:~$ vim .google/picasa/3.0/system.reg
---
[Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts] 1254213771
---
"VLPGothic"="VL-PGothic-Regular.ttf" <-追加
---

3 アプリケーション -> グラフィックス -> Picasa -> Picasa Font Configure を起動して、「Font Linking」タブの 「Linked Fonts」に「Add」ボタンをクリックして「VLPGthic」を追加。

4 ダイアログの「キャンセル」「適用」「ヘルプ」が化けるとき。

[Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes] 1254124511
---
"MS Shell Dlg"="Tahoma" -> "MS Shell Dlg"="VLPGothic"
"MS Shell Dlg 2"="Tahoma" -> "MS Shell Dlg 2"="VLPGothic"
---

Pisca ウェッブアルバムに接続
1 Picasa 右上の「Sign in to Web Album」をクリックします。
2 ユーザ名とパスワードを入力して「Sign In」ボタンをクリックします。
3 Picasa 右上の「Web Album」をクリックすると Pisca ウェッブアルバムが起動します。
4 Pisca3 の File -> Import from Web Album ... をクリックします。
5 Import Albums from Web Album で 「Import all album not ...」のチェックをはずし、必要なアルバムをチェックしたら「OK」ボタンをクリックします。
(日本語が表示されませんでした。)

Google Earth をインストール

1 Synaptic パッケージマネージャで「googleearth-package」をクリックしてインストール指定をクリックします。
2 「適用」ボタンをクリックします。
3 ターミナルで make-googleearth-package --force を実行します。

4 インストールします。
debian:/home/user# dpkg -i googleearth_5.1.3509.4636+0.5.4-1_i386.deb

5 文字化けしているので次のファイルを別の場所に移動します。
/usr/lib/google-earth/libQtCore.so.4
/usr/lib/google-earth/libQtGui.so.4
/usr/lib/google-earth/libQtNetwork.so.4
/usr/lib/google-earth/libQtWebKit.so.4

6 次のパッケージがなければSynaptic パッケージマネージャで次のパッケージをインストールします。
libqtcore4
libqtgui4
libqt4-network
libqt4-webkit

7 「アプリケーション」->「インターネット」->「Google Earth」をクリックします。

私の debian では Google Earth が起動できませんでした。

2009年10月6日火曜日

OpenLayers で東京都の地図表示 9 Google Pisca ウェッブアルバム の GeoRSS の表示

Google のサービスを使って画像を地図上に表示してみました。

1 Google Pisca ウェッブアルバムにログインします。

2 画像のないときはアップロードします。
2-1 「アップロード」ボタンをクリックします。
2-2 「新規アルバムを作成」リンクをクリックします。
2-3 「タイトル」を入力します。
「マップで場所を表示」は後で設定します。
「共有 マイギャラリーで」は「一般公開」にします。
「続行」ボタンをクリックします。
2-4 「アップロードする写真を選択」で「参照」ボタンをクリックして画像を選択します。
「アップロードを開始」ボタンをクリックしてアップロードします。

3 アルバムマップを作成します。
(位置情報がある画像は自動的に配置されるので確かめてみてください。)
3-1 「編集」をクリックして「アルバム マップ」をクリックします。
3-2 「場所を検索」に位置を入力して実行します。
3-3 サムネイルを選択し、マップをクリックして配置するか、サムネイルをマップ上にドラッグ アンド ドロップします。
3-4 「完了」ボタンをクリックします。
3-5 「アルバム表示に戻る」をクリックします。
3-6 RSS ボタンをクリックします。(アルバム表示右下)
3-7 URL をコピーします。

4 Google Pisca ウェッブアルバムの RSS を読み込むには、tokyo_bmi_pgis_img03.html に次のコードを追加します。

---
// ここから追加
var rsslayerURL2 = "http://picasaweb.google.com/data/feed/base/user/[user_id]/albumid/5264350151050308177?alt=rss&kind=photo&hl=ja";
var rssLayer2 = new OpenLayers.Layer.GeoRSS("Nishi Tachikawa", rsslayerURL2, {
visibility: false,
projection: new OpenLayers.Projection("EPSG:4326")
});
map.addLayer(rssLayer2);
// ここまで

map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.ScaleLine());
---

/usr/lib/cgi-bin/proxy.cgi を開いて次のように allowedHosts に
'picasaweb.google.com', 'picasaweb.google.co.jp' を追加します。
(ドメインが2つ [.com, .co.jp] あるので念のため両方追加してください。)

---
allowedHosts = ['www.openlayers.org', 'openlayers.org',
'labs.metacarta.com', 'world.freemap.in',
'prototype.openmnnd.org', 'geo.openplans.org',
'sigma.openplans.org', 'demo.opengeo.org',
'www.openstreetmap.org', 'sample.avencia.com',
'maps.google.co.jp', 'picasaweb.google.com',
'picasaweb.google.co.jp']
---