Google maps Google Map LatLngBounds for polygon.setPath

Google maps Google Map LatLngBounds for polygon.setPath,google-maps,google-maps-api-3,polygon,Google Maps,Google Maps Api 3,Polygon,假设我已经有一个多边形实例,并且我正在将贴图平移到边界,我还想将多边形移动到贴图的中心 是否有内置的方法将边界转换为多边形路径 理想情况下,我希望能够做到以下几点: polygon.setPaths(bounds.getBounds()); 只是用简单的老办法解决了这个问题: var polygon_paths_from_bounds = function(bounds){ var paths =new google.maps.MVCArray();

假设我已经有一个多边形实例,并且我正在将贴图平移到边界,我还想将多边形移动到贴图的中心

是否有内置的方法将边界转换为多边形路径

理想情况下,我希望能够做到以下几点:

polygon.setPaths(bounds.getBounds());

只是用简单的老办法解决了这个问题:

var polygon_paths_from_bounds = function(bounds){
            var paths =new google.maps.MVCArray();
            var path = new google.maps.MVCArray();
            var ne = bounds.getNorthEast();
            var sw = bounds.getSouthWest();
            path.push(ne);
            path.push(new google.maps.LatLng(sw.lat(), ne.lng()));
            path.push(sw);
            path.push(new google.maps.LatLng(ne.lat(), sw.lng()));
            paths.push(path);
            return paths;
        }

只是用简单的老办法解决了这个问题:

var polygon_paths_from_bounds = function(bounds){
            var paths =new google.maps.MVCArray();
            var path = new google.maps.MVCArray();
            var ne = bounds.getNorthEast();
            var sw = bounds.getSouthWest();
            path.push(ne);
            path.push(new google.maps.LatLng(sw.lat(), ne.lng()));
            path.push(sw);
            path.push(new google.maps.LatLng(ne.lat(), sw.lng()));
            paths.push(path);
            return paths;
        }

只是用简单的老办法解决了这个问题:

var polygon_paths_from_bounds = function(bounds){
            var paths =new google.maps.MVCArray();
            var path = new google.maps.MVCArray();
            var ne = bounds.getNorthEast();
            var sw = bounds.getSouthWest();
            path.push(ne);
            path.push(new google.maps.LatLng(sw.lat(), ne.lng()));
            path.push(sw);
            path.push(new google.maps.LatLng(ne.lat(), sw.lng()));
            paths.push(path);
            return paths;
        }

只是用简单的老办法解决了这个问题:

var polygon_paths_from_bounds = function(bounds){
            var paths =new google.maps.MVCArray();
            var path = new google.maps.MVCArray();
            var ne = bounds.getNorthEast();
            var sw = bounds.getSouthWest();
            path.push(ne);
            path.push(new google.maps.LatLng(sw.lat(), ne.lng()));
            path.push(sw);
            path.push(new google.maps.LatLng(ne.lat(), sw.lng()));
            paths.push(path);
            return paths;
        }

你的代码没有任何意义。将获取边界对象(矩形)并将其显示在地图上。这就是你想要的吗?我已经有了一个多边形实例,所以我不想创建一个新的实例。在你的问题中可以很好地解释一下。你的答案是唯一的方法(为多边形创建一个矩形路径),但要注意的是API总是在变化,将来可能会出现这种情况(你可以创建一个增强请求)。你的代码没有任何意义。将获取边界对象(矩形)并将其显示在地图上。这就是你想要的吗?我已经有了一个多边形实例,所以我不想创建一个新的实例。在你的问题中可以很好地解释一下。你的答案是唯一的方法(为多边形创建一个矩形路径),但要注意的是API总是在变化,将来可能会出现这种情况(你可以创建一个增强请求)。你的代码没有任何意义。将获取边界对象(矩形)并将其显示在地图上。这就是你想要的吗?我已经有了一个多边形实例,所以我不想创建一个新的实例。在你的问题中可以很好地解释一下。你的答案是唯一的方法(为多边形创建一个矩形路径),但要注意的是API总是在变化,将来可能会出现这种情况(你可以创建一个增强请求)。你的代码没有任何意义。将获取边界对象(矩形)并将其显示在地图上。这就是你想要的吗?我已经有了一个多边形实例,所以我不想创建一个新的实例。在你的问题中可以很好地解释一下。您的答案是唯一的方法(为多边形创建一个矩形路径),但需要注意的是,API总是在变化,将来可能会出现这种情况(您可以创建一个增强请求)。