PhoneGap调用GMap步骤

From Showing Cloud Knowledge Base
Jump to: navigation, search

PhoneGap调用谷歌地图三部曲

  1. 添加固定格式的javascript:
  2. 添加地图到你的程序例如:
    • <script type="text/javascript">
    • $(document).ready(function() {
    • // Also works with: var yourStartLatLng = '59.3426606750, 18.0736160278';
    • var yourStartLatLng = new google.maps.LatLng(59.3426606750, 18.0736160278);
    • $('#map_canvas').gmap({'center': yourStartLatLng});
    • });
    • </script>
  3. 最后在你的config.xml配置文件里面添加能加载远程js的域名例如:
    • <access origin="*://*.googleapis.com/*" subdomains="true" />
    • <access origin="*://*.gstatic.com/*" subdomains="true" />
    • <access origin="*://*.google.com/*" subdomains="true" />
    • <access origin="*://*.googleusercontent.com/*" subdomains="true" />