GoogleMapAPI を使ってサイトに地図を表示させたい場合

以下のようにするが、これを拡張したい場合がある。

その場合、自分で関数を作る時に関数を追加して

いけば良いのだが、IEだと上手く動作しない。

そこで以下の【 IE 対策 】のように書いたら動作した。

function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}


/*--
IE 対策
--*/
var map = "";

function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}