Hatena::Map::MyFavoritePlaceHack 0.02
ちょっとだけ改良してみました。0.01からの変更点は以下の通りです。
- はてなマップの縦幅をデフォルトよりも広くなるように変更
- コードのコメントを大幅に追加(英語)
ここからお試しください。
マップの縦幅は、idが"map"のdiv要素をDOMを使って調整しています。prototype.jsで提供されている$()関数を使うと、すっきり書けますね。
少し不都合があります。マップ中央にあるべきのターゲットマーカーが少し中央からずれてしまっています。ただ、マップをダブルクリックするとそのクリックした位置とターゲットマーカーの中央とがピッタリ一致するので、操作上は問題は無いと思います。ちょっと気になりますけど。
はてなマップをロードして間もない時に取ったスクリーンショットはこんな感じです。上が今回作成したgreasemonkeyスクリプトを適用したもので、下が普通のはてなマップです。たったこれだけのスクリプトでここまでできるのですね。
$ vi my.favorite.place.0.02.user.js // ==UserScript== // @name Hatena::Map::MyFavoritePlaceHack 0.02 // @namespace http://vaio.redirectme.net/lib/greasemonkey // @description Change the default place(hatena,Inc) to my favorite place whenever you load Hatena::Map. // @include http://map.hatena.ne.jp/* // ==/UserScript== (function() { // "favorite" variable below is at Haneda Airport. // The coordinate system here is WGS not Tokyo Datum. favorite = new GPoint(139.7890, 35.5457); // The argument order of MapUtil#japancheck() and MapUtil#wgs2tokyo() // are little confusing (lack of consistency). The spec should be improved. if (MapUtil.japancheck(favorite.x, favorite.y)) { p = MapUtil.wgs2tokyo(favorite.y, favorite.x); } // "map" is a GMap instance. // So, you can use any exported Google Maps API's functions. // Here is the example of the centerAndZoom() function. map.centerAndZoom(p, 0); // Tweak the height of the map. // The default value is 380px. // See the "Developer Notes for prototype.js covers version 1.3.1" // for the details of the "$()" utility function. $('map').style.height = '500px'; })();