TypeError: google.maps.latLng不是构造函数

TypeError: google.maps.latLng is not a constructor

本文关键字:构造函数 latLng maps google TypeError      更新时间:2023-09-26

我正在使用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>

我甚至不确定从谷歌地图API加载正确的数据。有人能帮我解决这个问题吗?

TypeError: google.maps.latLng不是构造函数

 google.maps.LatLng

代替

google.maps.Latlng.

就这些,在Google地图上运行得很好