首页 文章

如何在JQUERY Mobile上放置谷歌 Map ?

提问于
浏览
0

尝试运行代码时, Map 不会显示,并显示此错误 "Google Maps API warning: NoApiKeys " . 有什么可能的解决方案?这是我添加的脚本:

<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

这些是我放在js文件中的代码:

$(document).ready(function(){var myOptions = {zoom:11,center:new google.maps.LatLng(1.363083,103.909836),mapTypeId:google.maps.MapTypeId.ROADMAP}; var map = new google . maps.Map(document.getElementById('map_canvas'),myOptions);

var myLatlng = new google.maps.LatLng(1.443107  , 103.795681);
            var marker = new google.maps.Marker({
                position: myLatlng,
                map: map,
                title: "Map "
            })
        });

1 回答

  • 2

    该错误表明您未在Google Maps API调用中添加API密钥 . 您需要转到https://developers.google.com/maps/,注册API密钥,并将其包含在您的通话中 . 下面是一个使用JS api的简单示例 .

    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY></script>
    

相关问题