我正在尝试在美国县周围建立一个多边形。多边形的坐标来自数据库和 json 编码以在 javascript 中使用。这是来自 php 代码的 json 编码数组
{"Abbeville-sc":[["34.02593","-82.59388"],["34.02629","-82.59383"],["34.03162","-82.5975"],["34.04056","-82.60997"],["34.05677","-82.62081"],["34.06238","-82.62598"],["34.0649","-82.63427"],["34.06788","-82.64052"],["34.07661","-82.64548"],["34.08025","-82.64416"],["34.08676","-82.64022"],["34.09155","-82.64131"],["34.0947","-82.64426"],["34.09827","-82.64744"],["34.09987","-82.65131"],["34.10116","-82.65488"]]}
我构建多边形的方式如下:
var points = []
for(j=0;j < counties[i].length;j++)
{
var Latit = parseFloat(counties[i][j][0]);
var Longit = parseFloat(counties[i][j][1]);
var ll = new google.maps.LatLng(Latit,Longit);
points.push(ll);
}
var county = new google.maps.Polygon({
paths: points,
strokeColor: '#000',
strokeOpacity: 0,
strokeWeight: 2,
fillColor: '#000',
fillOpacity: 0
});
其中counties[i] 是abbeville-sc。我遇到的问题是它没有按预期创建多边形。任何形式的帮助将不胜感激。