Groups
Groups
Sign in
Groups
Groups
Google-Maps-API-Japan
Conversations
About
Send feedback
Help
日本語以外の言語設定の場合にボタン名で表示形式を取得する方法
9 views
Skip to first unread message
W少年
unread,
Sep 29, 2009, 11:55:58 PM
9/29/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google-Maps-API-Japan
こんにちは、W少年です。グーグルマップで選択した表示形式を取得する際、ボタン名で判断して取得していますが、その方法だとブラウザの表示言語で日本
語が設定されていない場合ボタン名でうまく判断できないことがあります。例えば、ボタン名が英語になっていても地図の表示形式を取得できるようにするに
はどうしたらいいでしょうか。
Message has been deleted
Masashi.K
unread,
Sep 30, 2009, 12:11:07 AM
9/30/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google-Maps-API-Japan
Google Maps API が読み込まれたときの言語を取得するには
「GLanguage」を使うとできますよ。
GLanguage
http://code.google.com/intl/en/apis/maps/documentation/reference.html#GLanguage
GLanguage.getLanguageCode();
で取得できます。
ボタン名で判断するよりは確実なのでオススメですよ。
------------
または地図に表示される言語を固定する方法もあります。
http://code.google.com/intl/ja/apis/maps/documentation/index.html#Localization
例えば hl=ja とすれば、日本語で表示してくれます。
ご参考になれば幸いです。
W少年
unread,
Sep 30, 2009, 12:49:05 AM
9/30/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google-Maps-API-Japan
ありがとうございました。この方法でマップで使用している言語を取得できるのですね。
訊き方が間違っていたようでスミマセン。
var type = map.getCurrentMapType().getName();
if (type == '航空写真') {
query[query.length] = "type=" + 'SATELLITE';
} else if (type == '地図+写真') {
query[query.length] = "type=" + 'HYBRID';
} else if (type == '地形') {
query[query.length] = "type=" + 'PHYSICAL';
} else if (type == 'Earth') {
query[query.length] = "type=" + 'SATELLITE_3D';
}
というスクリプトで現在のMapTypeを取得して、queryをURLにつないでメールで送ったURLを開けば送信者が見てほしいサイトの状態を再現
できるようにしようとしているのですが、この方法でMapTypeが取得できるのはLanguageが日本語の場合だけですよね。ゆくゆくはサイトの国
際化をと考えて英訳されたサイトの作成も考えていますが、そのばあい、マップのボタン名はクライアントの環境によって変わる状態のほうがいいですよね。
どのLanguageが指定されていてもLanguageを変えることなくMapTypeを取得できるようにするにはどうしたらいいですか。
W少年
unread,
Sep 30, 2009, 1:15:43 AM
9/30/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google-Maps-API-Japan
もう少し調べてみたら、以下のスクリプトを使うとどの言語でも同じ結果を得ることができるようです。
map.getCurrentMapType().getUrlArg()
このときに返される文字とMapTypeの対応関係を教えてください。
Masashi.K
unread,
Sep 30, 2009, 1:35:53 AM
9/30/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google-Maps-API-Japan
カレントマップタイプが何か知りたいだけなら
if (map.getCurrentMapType() === G_NORMAL_MAP) {
alert("通常のマップタイプ");
}
とすると、できますよ。
W少年
unread,
Oct 1, 2009, 10:20:47 AM
10/1/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google-Maps-API-Japan
うまくいきました。ありがとうございます。
Reply all
Reply to author
Forward
0 new messages