我正在尝试将 PolyLine 对象添加到地图中,但收到错误消息“google.maps.Polyline not a constructor”。对我来说,这表明我无法导入此类的定义,但我在声明中遗漏的任何示例中都看不到任何内容。我将 Google Maps API 包括在内,如下所示:
<!DOCTYPE HTML >
<html>
<head>
<title>
Location: Caradoc, Middlesex, ON, CA
</title>
<meta charset='utf-8'>
<meta http-equiv='default-style' content='text/css'>
<meta name='author' content='James A. Cobban'>
<meta name='copyright' content='© 2013 James A. Cobban'>
<meta name='keywords' content='genealogy, family, tree, ontario, canada'>
<link rel='stylesheet' type='text/css' href='http://localhost/styles.css'/>
<script src='../jscripts/js20/http.js' type='text/javaScript'>
</script>
<script src='../jscripts/CommonForm.js' type='text/javaScript'>
</script>
<script src='../jscripts/util.js' type='text/javaScript'>
</script>
<script src='../tinymce/jscripts/tiny_mce/tiny_mce.js' type='text/javaScript'>
</script>
<script src='http://maps.googleapis.com/maps/api/js?sensor=false®ion=CA' type='text/javaScript'>
</script>
<script src='LegacyLocation.js' type='text/javaScript'>
</script>
</head>
几年来,我一直在使用它来显示地图。但现在我希望使用折线来显示区域的边界。
var path = [], poly;
function mapClick(mouseEvent)
{
if (path.length == 0)
{ // first click
var polyOptions = {map: map,
strokeColor: "red",
stokeOpacity: 0.5,
strokeWeight: 2};
poly = new google.maps.PolyLine(polyOptions);
} // first click
path.push(mouseEvent.latLng);
poly.setPath(path);
}
我收到错误的那一行是直接从本网站上的一篇文章复制而来的。