Jquery 谷歌地图API(地图不显示)
我很困惑。我第一次使用GoogleMapsAPI(V3版),我不明白为什么jQueryOnReady速记不起作用Jquery 谷歌地图API(地图不显示),jquery,google-maps,Jquery,Google Maps,我很困惑。我第一次使用GoogleMapsAPI(V3版),我不明白为什么jQueryOnReady速记不起作用 <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=set_to_true_or_false"> </script> <script type="text/javascript"> function initialize()
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=set_to_true_or_false">
</script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),
myOptions);
}
</script>
也许你的问题是
你把它设为真还是假?
顺便问一下,您是否链接到有效的jQuery js工作表?
你有合适的
吗?对不起,这很明显
我正在定义初始化,但没有调用它 你能展示一下你用过但不起作用的代码吗?顺便说一句,您需要将传感器设置为
true
或false
我认为您在前两次调用中没有调用initalize()
。onload应该是窗口。onload=initialize是的,我想你是对的。我定义了这个函数,但没有在这里调用它,嗯?我对GET参数的理解不好。在我的代码中,我确实将传感器设置为false,而JQuery则通过我的codeWait工作,所以您的问题得到了解决还是仍然被卡住了?顺便说一句,在加载自定义JS之前,请确保jQuery库已连接。我刚刚遇到了相同的问题,您的回答为我节省了一些时间!
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
$(function(){
function initialize() {
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map")
,
myOptions);
}
});