1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IEだけgoogleMapが表示されない時にやったこと

Posted at

googleMapAPIを使用して開発をした時に困ったことのメモ。

googleMapの表示要件

-初期表示は、map1個だけ表示
  gmap_0001.png
  gmap_0002.png

-ラジオボタン「集合場所と異なる」選択時(2つめのmap現れる)
  gmap_0001.png
  gmap_0003.png

実装内容

最初は、画面表示時にmapを2つとも呼び出していました。
(2つめは呼び出した上でdisableにしていた。)

viewヘッダ
    <script>
        $(document).ready(function(){
            creategooglemap("1");
            creategooglemap("2");
        });
    </script>

が、なぜかIEだけ2つめの表示がうまくいかない。。。(グレーになる。)

ググると、IEとgoogleMapの相性が良くないのか?困っている人多数。
ネットで調べていろいろとやってみましたが、解消せず。

-IEの互換表示設定を解除
-ヘッダーに以下記載

viewヘッダ
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="Thu, 01 Dec 1994 16:00:00 GMT">

等。。。

試行錯誤の結果、2つめのmapの表示処理を、画面ロード時ではなく、
ラジオボタンを押下時に移動したところ、無事表示できるようになりました!

viewヘッダ
    <script type="text/javascript">
            function changeDisabled() {
                if ( document.event["radio"][1].checked ) {
                        creategooglemap("2");
                }
            }
    </script>

結論

2つのmap別々の箇所にマーカーがドロップされている状態の場合は、表示できるので、
同じタイミングで2つ開こうとすると、同じものとみなしてしまうようです。
2つめのmapは最初から表示しなくてもいいよ、という場合には試してみてはどうでしょうか?

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?