2011-10-19 17 views
0

jQueryモバイルの場合は、私はnoobieですが、私は足を濡らしています。jQueryモバイルとGoogleマップが表示されない

要点は2ページのモバイルサイトです。ページ1は、ユーザーがいくつかのオプションを選択する単純なフォームです。フォームが提出されると、2つ目のページにリダイレクトされ、「地図キャンバス」が含まれます。しかし何らかの理由で、次のページは空白です。ときどきバックボタンを押すと地図が表示されますが、簡単に表示されます。私は困惑している!

私はjQuery 1.6.4とjQuery Mobile 1.0rc1を使用しています。

ページワンHTML::

<div data-role="page" id="one"> 
    <div data-role="content"> 
     <div data-role="fieldcontain"> 
      <form action="" id="mobile-findpath" method="post"> 
       <label for="mobile-start" class="select">Start:</label> 
       <select name="start" id="mobile-start"> 
        <option data-placeholder="true" value="">Current Position</option> 
        {% for node in nodes %} 
        <option value="{{ node.lat }},{{ node.lng }}">{{ node.label }}</option> 
        {% endfor %} 
       </select> 
       <label for="mobile-end" class="select">Dest:</label> 
       <select name="end" id="mobile-end"> 
        {% for node in nodes %} 
        <option value="{{ node.label }}">{{ node.label }}</option> 
        {% endfor %} 
       </select> 
       <a href="/m-map/" data-role="button" data-icon="gear">Show Route</a> 
       <!--<a href="#two" data-role="button" data-icon="gear">Show Route</a>--> 
      </form> 
     </div> 
    </div> 
</div> 

ページ2(マップ)HTML:

<div data-role="page" data-title="Map" data-theme="b" class="page-map" style="width:100%; height:100%;"> 
    <div data-role="header"><h1>Map</h1></div> 
    <div data-role="content" style="width:100%; height:100%; padding:0;"> 
     <div id="map_canvas" style="width:100%; height:100%;"></div> 
    </div> 
</div> 

関連JS:

ここ

は、私のコードの一部であります

$(".page-map").live("pagecreate", function() { 
    wMobile = WayFinderMobile(); 
    if(navigator.geolocation) { 
     navigator.geolocation.getCurrentPosition(function(position){ 
      wMobile.initialize(position.coords.latitude, position.coords.longitude, true); 
     }); 
    } else { 
     wMobile.initialize(38.94617, -92.32866); 
    } 
}); 

答えて

3

それは私の問題は2倍であったように、

一つが問題だったに見えますが、私は、マップキャンバスのdivのため

<div data-role="content" style="padding:0px;margin:0;"> 
     <div id="map_canvas" style="width:100%;height:350px;"></div> 
</div> 

を幅と高さを指定する必要がありました。また、私が設定しなければならなかったということでしたマップがあったページの "pageshow"イベントで作成するマップ。

関連する問題