好吧,這是我第一次在使用Google地圖時看到這個問題。JS中未捕獲的奇怪錯誤
我有2個簡單的文件(HTML & JS),它似乎是其中之一是造成這些錯誤
HTML
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/test.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="map.js"> </script>
</head>
<body>
<div id="test">
<iframe id="map" width="100%" height="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?hl=en&ie=UTF8&ll=37.0625,-95.677068&spn=56.506174,79.013672&t=m&z=4&output=embed"></iframe>
</div>
</body>
</html>
的Java腳本
$(document).ready(function() {
initialize();
function initialize() {
var myOptions = {
zoom: 4,
center: new google.maps.LatLng(-33, 151),
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"),
myOptions);
}
});
錯誤
map.js:1 Uncaught ReferenceError: $ is not defined(anonymous function) @ map.js:1 util.js:138 XHR finished loading: GET " https://www.google.com/maps/vt?pb=!1m4!1m3!1i4!2i1!3i5!1m4!1m3!1i4!2i1!3i6 !…ty_class!2s0!12m1!1e47!12m3!1e37!2m1!1ssmartmaps!4e3!12m1!5b1&token=114164".SF @ util.js:138_.TF @ util.js:138(anonymous function) @ onion.js:9XU.load @ onion.js:71$U @ onion.js:15YU.l @ onion.js:71 util.js:138 XHR finished loading: GET " https://www.google.com/maps/vt?pb=!1m4!1m3!1i4!2i4!3i7!1m4!1m3!1i4!2i5!3i6 !…ity_class!2s0!12m1!1e47!12m3!1e37!2m1!1ssmartmaps!4e3!12m1!5b1&token=15750".
我想要做的只是很簡單,我試圖禁用谷歌地圖選項。
您試圖在明顯使用JQuery時未加載它。 – Carcigenicate
你有jQuery包含嗎? – empiric
看起來像它需要'jquery' –