google.maps.geometry.spherical错误 [英] google.maps.geometry.spherical error
本文介绍了google.maps.geometry.spherical错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在使用谷歌地图上的几何图形时遇到了一些麻烦。我收到以下错误:
无法获取未定义或空引用的属性'spherical'。
I am having some troubles using the geometry at google maps. I am getting the following error: "Unable to get property 'spherical' of undefined or null reference."
这是w3c的一些代码, 。
This is some code from w3c with some additions of mine.
var x=new google.maps.LatLng(52.395715,4.888916);
var stavanger=new google.maps.LatLng(58.983991,5.734863);
var amsterdam=new google.maps.LatLng(52.395715,4.888916);
var london=new google.maps.LatLng(51.508742,-0.120850);
function initialize()
{
var mapProp = {
center:x,
zoom:4,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var myTrip=[stavanger,amsterdam,london];
var flightPath=new google.maps.Polyline({
path:myTrip,
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2
});
flightPath.setMap(map);
try{
var markerpos = google.maps.geometry.spherical.interpolate(flightPath.getAt(0), flightPath.getAt(1), .5);
// also tried //
//var Spherical = google.maps.geometry.spherical;
//var markerpos = Spherical.interpolate(flightPath.getAt(0), flightPath.getAt(1), .5);
//var markerpos = google.maps.geometry.spherical.interpolate(amsterdam, london, .5);
}
catch(ex){alert(ex);}
var marker = new google.maps.Marker({position: markerpos,
map: map, clickable: false
});
}
上面的代码有什么问题?
What is wrong with the above code?
推荐答案
您是否正在加载正确的库与 libraries =
参数?
Are you loading the correct library with the libraries=
parameter?
<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false&libraries=geometry"></script>
这篇关于google.maps.geometry.spherical错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文