Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在谷歌地图上创建一个网格并获取坐标_Javascript_Google Maps - Fatal编程技术网

Javascript 在谷歌地图上创建一个网格并获取坐标

Javascript 在谷歌地图上创建一个网格并获取坐标,javascript,google-maps,Javascript,Google Maps,我从这个链接中获取了这段代码 这将围绕中心点创建一个正方形。我现在需要解决的是如何在主正方形周围创建许多其他正方形,使右边缘和上边缘对齐,从而创建网格。网格应仅从原始正方形向右和向上移动 我试过这个: for(var i = 0; i < 10; i++) { var point = new google.maps.LatLng(square.getBounds().getNorthEast().lat(), square.getBounds().getNorthEast().ln

我从这个链接中获取了这段代码

这将围绕中心点创建一个正方形。我现在需要解决的是如何在主正方形周围创建许多其他正方形,使右边缘和上边缘对齐,从而创建网格。网格应仅从原始正方形向右和向上移动

我试过这个:

for(var i = 0; i < 10; i++)
{
    var point = new google.maps.LatLng(square.getBounds().getNorthEast().lat(), square.getBounds().getNorthEast().lng());

    var square = new google.maps.Rectangle({bounds:(new google.maps.Circle({center: point, radius: radius}).getBounds()),
        strokeColor: "#ff0000",
        strokeWeight: 1,
        strokeOpacity: 1.0,
        fillOpacity: 0.0
    });
    square.setMap(map);
}
for(变量i=0;i<10;i++)
{
var point=new google.maps.LatLng(square.getBounds().getNorthEast().lat(),square.getBounds().getNorthEast().lng());
var square=new google.maps.Rectangle({bounds:(new google.maps.Circle({center:point,radius:radius}).getBounds()),
strokeColor:#ff0000“,
冲程重量:1,
笔划不透明度:1.0,
填充不透明度:0.0
});
正方形。setMap(地图);
}
但这将从最后一个点的西北点创建新的方形中心。如果可能,我想指定网格的大小,即100 x 100

谢谢

可能的副本可能的副本
for(var i = 0; i < 10; i++)
{
    var point = new google.maps.LatLng(square.getBounds().getNorthEast().lat(), square.getBounds().getNorthEast().lng());

    var square = new google.maps.Rectangle({bounds:(new google.maps.Circle({center: point, radius: radius}).getBounds()),
        strokeColor: "#ff0000",
        strokeWeight: 1,
        strokeOpacity: 1.0,
        fillOpacity: 0.0
    });
    square.setMap(map);
}