Javascript TypeError:google.maps.latLng不是构造函数
我正在使用Firefox加载我的html文件进行地理定位。问题是,我在控制台中收到以下两条消息:Javascript TypeError:google.maps.latLng不是构造函数,javascript,google-maps,geolocation,Javascript,Google Maps,Geolocation,我正在使用Firefox加载我的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 charse
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>
领航员
x=navigator.geolocation;
x、 getCurrentPosition(成功、失败);
功能成功(职位){
//获取坐标
var mylat=位置坐标纬度;
var mylong=位置坐标经度;
//google api就绪纬度和经度字符串
var coords=new google.maps.latLng(mylat,mylong);
//设置谷歌地图
变量映射选项={
缩放:16,
中心:coords,
mapTypeId:google.maps.mapTypeId.ROADMAP
}
//创建地图
var map=new google.maps.map(document.getElementById(“map”)、mapOptions);
}
函数失效(){
$('#lat').html(“没有坐标可用!”);
}
我甚至不确定GoogleMapAPI中的数据是否正确加载。
有人能帮我解决这个问题吗?类型错误:google.maps.latLng不是构造函数
google.maps.LatLng
使用代替
google.maps.Latlng.
仅此而已,在谷歌地图上工作得很好。再次输入:LatLng()而不是LatLng()。伙计们,你们都有足够高的代表性,知道Anto应该发布一个答案,Cyzanfar应该接受它,以帮助将来阅读此问题的其他人。