1
我想將一個PolyLine對象添加到地圖,但我收到錯誤消息「google.maps.Polyline不是構造函數」。對我來說,這表明我無法導入這個類的定義,但我沒有看到任何我從聲明中遺漏的任何示例。我包括谷歌地圖API如下:google.maps.Polyline不是構造函數
<!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>
我一直在使用它來顯示幾年來的地圖。但是現在我希望使用PolyLine來顯示區域的邊界。
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);
}
我得到的錯誤行直接從本網站上的其中一個帖子複製。