google maps v3:绘制折线时构造函数参数0的值无效
google maps v3: Invalid value for constructor parameter 0 while drawing polylines
我有一个问题,当构建一个多边形。错误信息显示如下:
构造函数参数0的无效值:(49.27862248020283,-122.79301448410035),(49.277964542440955,-122.79370112960816),(49.278524490028595,-122.7950207764435)
它一定是非常简单的东西,但我就是看不出来。你的建议都很有用。
我基本上是画一个地图在一个模态窗口(与wicket)的iframe内。一切都很好,但当我试图显示一个多边形(点是从数据库加载并由webservice发送),我得到错误消息。
iframe code:
/**
* Draws the polygon.
*/
function drawPolygon() {
if (order >= 3) {
deleteMarkers();
// Construct the polygon
// Note that we don't specify an array or arrays, but instead just
// a simple array of LatLngs in the paths property
polygonObject = new google.maps.Polygon({
paths: polygonCoords,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35
});
polygonObject.setMap(map);
isPolygonDrawed = true;
//After we create the polygon send the points to wicket
parent.sendPoints();
//Change the message on the top label
controlText.style.color = '#ADAAAA';
controlText.innerHTML = polygonCreated;
//With this we make sure no other markers are created after the polygon is drawed.
//Is assigned (order - 1) because when this code is called the order has already been added 1.
MAX_POLYGON_VERTEX = order - 1;
//Disable the create polygon button.
enable = false;
createControlText.style.color = '#ADAAAA';
}
else alert(alertMessage);
}
现在父窗口(模态窗口)上的代码 /**
* Show the polygon on map.
*/
function showPolygon(zoneId) {
var url = applicationRootUrl + 'zonePointsOnMap?zoneId=' + zoneId;
$.getJSON(url, function(data) {
if(data.length == 0) {
return false;
}
frames['zoneMapIFrame'].order = parseInt(data.length);
alert(data.length);
$.each(data, function(i, item) {
if(item != null) {
if(item.latitude != null && item.longitude != null) {
var lat = parseFloat(item.latitude);
var lng = parseFloat(item.longitude);
var latlng = new google.maps.LatLng(lat, lng);
var pointOrder = item.order;
frames['zoneMapIFrame'].polygonCoords[pointOrder] = latlng;
alert(item.order + " point " + latlng);
frames['zoneMapIFrame'].bounds.extend(latlng);
}
}
});
});
setTimeout("frames['zoneMapIFrame'].drawPolygon()", 200);
setTimeout("frames['zoneMapIFrame'].fitMapZoomPolygon()", 300);
}
我可以看到这些点加载了警报,但是我一直得到错误信息。
帮帮我!
我也有同样的问题。我不知道这是不是最好的解决方案,可能不是,但它对我很有效。
问题是拉丁文没有被识别出来。所以我重新创建了这个数组
var lats = [];
var lat_size = steps[step].lat_lngs.length;
for (var t=0; t <lat_size; t++) {
lats.push(new google.maps.LatLng(steps[step].lat_lngs[t].lat(), steps[step].lat_lngs[t].lng()))
}
var polylineOptions = {
map: map,
path: lats
}
new google.maps.Polyline(polylineOptions);
相关文章:
- $.Ajax投掷“;无效的参数"在IE9上
- 在 IE8 中接收无效参数
- fancydropdown js:IE8 中的参数无效
- 使用空媒体查询调用matchMedia失败,IE中的参数无效
- 单元测试输入参数无效的promise
- AngularJS IE11参数无效
- 数据表1.8.0添加服务器参数无效
- IE8 中的参数无效
- PHP foreach 提供的参数无效
- 管道“异步管道”的参数无效
- 使用 response.js 的参数无效,适用于 IE8
- SCRIPT87:IE 9、ASP.NET C#中的参数无效
- 数组缓冲区IE10-类型化的数组构造函数参数无效
- foreach参数无效
- 从url中删除参数无效
- 命令行参数无效,验证您正在使用的交换机
- chrome.runtime.sendMessage未捕获错误:要连接的参数无效
- IE中存在AJAX请求错误,参数无效
- 严重性:警告消息:为 foreach() 提供的参数无效 文件名:帮助程序/form_helper.php
- grant_type参数无效或缺少参数