<分区>
我正在使用 Firefox 为 GeoLocation 加载我的 html 文件。问题是我在控制台中收到了这两条消息:
TypeError: google.maps.latLng is not a constructor index.html:26
error in parsing value for 'background'. Declaration dropped.
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Navigator</title>
</head>
<script src="js/jquery.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script>
x = navigator.geolocation;
x.getCurrentPosition(success, failure);
function success(position) {
// fetch coordinates
var mylat = position.coords.latitude;
var mylong = position.coords.longitude;
// google api ready latitude and longitude string
var coords = new google.maps.latLng(mylat, mylong);
// setting up out google map
var mapOptions = {
zoom: 16,
center: coords,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
// CREATING MAP
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
}
function failure() {
$('#lat').html("<h3> No co-ordinates available!</h3>");
}
</script>
<body>
<!--map placeholder -->
<div id="map">
</div>
<div id="lat"></div>
<div id="long"></div>
</body>
</html>
我什至不确定来自 Google Map API 的数据是否正确加载。 有人可以帮我解决这个问题吗?