如何在JQUERY Mobile上放置谷歌地图

How to put a google map on JQUERY Mobile?

本文关键字:谷歌地图 Mobile JQUERY      更新时间:2023-09-26

当尝试运行代码时,映射没有显示,并且显示此错误"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 "
                })
            });

该错误表明您的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>