简体   繁体   English

科尔多瓦3.3 Android和Google地图,出现Chromium错误

[英]Cordova 3.3 Android and Google maps, Chromium error

Just I'm trying to have a min example of Google maps working on Cordova Android. 我只是想举例说明在Cordova Android上运行的Google地图。 The code works fine on localhost with Chrome and Firefox, but i can't get it work on the device. 该代码在带有Chrome和Firefox的localhost上运行良好,但我无法在设备上正常运行。

Example code: 示例代码:

<!DOCTYPE html>
<html>
    <head>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script>
        <script type='text/javascript'>
            window.addEventListener('deviceready',function(){
                var latitud = xx.xxxxxxx;
                var longitud = x.xxxxxxxxxxxxxxxx;
                success(latitud,longitud);
            },true);  

            function success(latitud,longitud) {
                var coords = new google.maps.LatLng(latitud, longitud);

                var options = {
                zoom: 15,
                center: coords,
                mapTypeControl: false,
                navigationControlOptions: {
                    style: google.maps.NavigationControlStyle.SMALL
                },
                mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                var map = new google.maps.Map(document.getElementById("prova_maps"), options);

                var marker = new google.maps.Marker({
                  position: coords,
                  map: map,
                  title:"You are here!"
                });
            }
        </script>
    </head>
    <body> 
        <h1>Google Maps</h1>
        <div id='prova_maps' style='height:250px;width:250px;'></div>

    </body>
</html>

I have the following error at console that is directly relaunched with that problem, but can't find a solution for that: 我在直接重新启动该问题的控制台上遇到以下错误,但找不到针对该问题的解决方案:

https://imageshack.com/i/f3myppp https://imageshack.com/i/f3myppp

I have the access tags added in config.xml. 我在config.xml中添加了访问标签。

And even try to add 甚至尝试添加

And in index.html 并在index.html中

<script type="text/javascript" src="../platform/js/libs/cordova.js"></script>

Try to add this link in the script...tag 尝试在脚本中添加此链接...标签

google.maps.event.addDomListener(window, 'load', initialize); google.maps.event.addDomListener(窗口,“加载”,初始化);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM