2

我試圖從WebWorks應用程序內顯示Google地圖。這是在應用程序,網頁的完整的HTML(注意,在瀏覽器中正常工作):在BlackBerry WebWorks應用程序中顯示Google地圖

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
    <head> 

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no" /> 

    <title>Waste Management Service Request</title> 

    <style type="text/css"> 
     body { 
     min-height: 500px; 
     } 
     .center { 
     text-align: center; 
     } 
     #page { 
     font-family: Arial, sans-serif; 
     font-size: 85%; 
     width: 408px; 
     margin: 0 auto; 
     padding: 0 30px; 
     } 
     h3 { 
     color: #006A3C; 
     } 
     #map-canvas { 
     height: 300px; 
     } 
    </style> 

    <script type="text/javascript" src="jquery.min.js"></script> 
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
    <script type="text/javascript"> 

     if (typeof(blackberry) != "undefined") { 
     blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, function() { 
      history.back(); 
     }); 
     } 

     $(document).ready(function(){ 

     var geocoder, map; 
     geocoder = new google.maps.Geocoder(); 
     var latlng = new google.maps.LatLng(-34.397, 150.644); 
     var mapOptions = { 
      zoom: 8, 
      center: latlng, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     } 
     map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); 

     address = '100 1st St., New York City, NY'; // Hardcoded for testing. 
     geocoder.geocode({'address': address}, function(results, status) { 
      if (status == google.maps.GeocoderStatus.OK) { 
      map.setCenter(results[0].geometry.location); 
      var marker = new google.maps.Marker({ 
       map: map, 
       position: results[0].geometry.location 
      }); 
      } else { 
      alert("The map failed because: " + status); 
      } 
     }); 

     }) 
    </script> 

    </head> 
    <body> 

    <div id="page"> 
     <h3>Local Map</h3> 
     <div id="map-canvas"></div> 
    </div> 

    </body> 
</html> 

從應用程序中,它只是顯示一個灰色框,應用程序應該會出現。

請注意,代碼主要從this example page的源代碼中抽取,該代碼鏈接從here鏈接。

任何想法?我最好在這裏採用Google提供動態呈現靜態圖像的方式(即this technique),還是有些東西我錯過了以獲取真實的東西?

順便說一句,我試着爬過gmaps的JS調用堆棧,並將每個域添加到應用程序權限列表中。我擁有gmaptiles.co.kr,google.com,googleapis.com和gstatic.com的權限條目(包括http和https)。

回答

1

您使用的是什麼版本的模擬器?在0.9.4之前的版本中有known issue,當在URL上傳遞參數時以及在訪問本地文件時導致問題。您可以嘗試鏈接到外部JQuery庫以排除最後一點(不要忘記爲其添加<access>元素)?

您可以發佈您在config.xml中定義的<access>元素嗎?我想知道你是否需要subdomains="true"或類似的東西?

<access subdomains="true" uri="http://maps.google.com/maps/api/js"/> 

除此之外,我建議你保持從頁面剝離出來的內容,直到出現的東西,例如刪除meta name="viewport"線,並從那裏去...

0

好吧,我得到了你的問題的答案,我認爲!嘗試使用JQuery 1.5而不是1.5.1。 JQuery 1.5.1似乎在WebWorks中被打破了,這是非常蹩腳的!

+0

我剛剛發現的另一個問題WebWorks系統並未指出基於頭部的ajax請求,這破壞了檢測到ajax請求的CakePHP系統,返回html而沒有等標籤。沒有樂趣調試這個東西! – Russell 2011-03-21 04:00:59

1

我正在使用谷歌地圖,它使用BB瀏覽器版本6運行正常,但不在5(div只有灰色)。這與JQuery 1.5.1。

我用於測試,谷歌地圖也使用其他域。

1

您的代碼就可以了,只需要照顧config.xml文件,提供訪問權域,這個工作對我來說:

<access subdomains="true" uri="http://gstatic.com"/> 
    <access subdomains="true" uri="http://google.com"/> 
    <access subdomains="true" uri="http://googleapis.com"/> 

最後,BB6這只是工作...

-1

爲BB操作系統設置地圖div z-index爲0

相關問題