0

好的,我在加载地图时遇到了这个问题,这部分将“google”显示为undefined.

var polyline = [
    new Google.map.LatLng(3.032617, 101.376),
    new Google.map.LatLng(3.03255, 101.3759),
    new Google.map.LatLng(3.032467, 101.3758),
    new Google.map.LatLng(3.031867, 101.3753),
    new Google.map.LatLng(3.0318, 101.3753)
];

var polylineopts = {
  path: polyline,
  map: map,
  strokecolor: 'blue',
  strokeopacity: 1.6,
  strokeweight: 3,
  geodesic: true
};

var poly = new google.maps.Polyline(polylineopts);
4

1 回答 1

2

我预计错误是“Google”未定义。Javascript 区分大小写。

应该:

var polyline = [
    new google.maps.LatLng(3.032617, 101.376),
    new google.maps.LatLng(3.03255, 101.3759),
    new google.maps.LatLng(3.032467, 101.3758),
    new google.maps.LatLng(3.031867, 101.3753),
    new google.maps.LatLng(3.0318, 101.3753)
];

var polylineopts = {
  path: polyline,
  map: map,
  strokecolor: 'blue',
  strokeopacity: 1.6,
  strokeweight: 3,
  geodesic: true
};

var poly = new google.maps.Polyline(polylineopts);

工作示例

于 2013-05-21T06:01:32.297 回答