Google maps 谷歌地图-根据4个坐标绘制椭圆

Google maps 谷歌地图-根据4个坐标绘制椭圆,google-maps,google-maps-api-3,coordinates,Google Maps,Google Maps Api 3,Coordinates,我想根据四个坐标在谷歌地图上画一个椭圆,就像当前通过API可用的“矩形”方法一样: var rectangle = new google.maps.Rectangle({ strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.35, ma

我想根据四个坐标在谷歌地图上画一个椭圆,就像当前通过API可用的“矩形”方法一样:

var rectangle = new google.maps.Rectangle({
          strokeColor: '#FF0000',
          strokeOpacity: 0.8,
          strokeWeight: 2,
          fillColor: '#FF0000',
          fillOpacity: 0.35,
          map: map,
          bounds: new google.maps.LatLngBounds(
            new google.maps.LatLng(33.671068, -116.25128),
            new google.maps.LatLng(33.685282, -116.233942))
        });
(使用边界参数)


如果失败,是否有一种简单的方法将两个多边形之间的距离转换为测量单位?

您必须自己计算路径。这将有助于:

编辑:这可能更有用:

的v3端口支持椭圆(但不基于边界)

大小与地图边界一致

代码片段:

var-map=null;
变量myOptions={
缩放:8,
中心:新google.maps.LatLng(43,-79.5),
mapTypeControl:true,
mapTypeControlOptions:{
样式:google.maps.MapTypeControlStyle.DROPDOWN_菜单
},
导航控制:对,
mapTypeId:google.maps.mapTypeId.ROADMAP
}
map=new google.maps.map(document.getElementById(“map”),
肌肽);
google.maps.event.addListenerOnce(映射,“边界更改”,函数(){
var bounds=map.getBounds();
var major_axis=google.maps.geometry.sphereal.ComputedIstanceBeween(bounds.getNorthEast(),new google.maps.LatLng(bounds.getSouthWest().lat(),bounds.getNorthEast().lng())/2;
var minor_axis=google.maps.geometry.spheremic.ComputedDistanceBetween(
新的google.maps.LatLng(bounds.getCenter().lat(),bounds.getsoutwest().lng()),
新的google.maps.LatLng(bounds.getCenter().lat(),bounds.getNorthEast().lng())/2;
//==椭圆===
var point=map.getCenter();//新建google.maps.LatLng(43,-78);
var椭圆=google.maps.Polygon.ellipse(点,长轴,短轴,0,“#000000”,2,1,“#ffff00”,0.5);
椭圆.setMap(map);
});
//此Javascript基于
//社区教会Javascript团队
// http://www.bisphamchurch.org.uk/   
// http://econym.org.uk/gmap/
//EShapes.js
//
//基于“thetoy”的一个想法和几行代码
//
//此Javascript由Mike Williams提供
//社区教会Javascript团队
//   http://www.bisphamchurch.org.uk/   
//   http://econym.org.uk/gmap/
//
//本作品根据知识共享许可证获得许可
//   http://creativecommons.org/licenses/by/2.0/uk/
//
//版本0.0 04/Apr/2008尚未完成
//版本1.0 2008年4月10日首次发布
//Lawrence Ross于2011年10月12日将版本3.0移植到v3
google.maps.Polygon.Ellipse=函数(点、r1、r2、旋转、strokeColour、strokeWeight、StrokeCapacity、FillColor、fillOpacity、opts){
旋转=旋转| | 0;
返回google.maps.Polygon.Shape(点,r1,r2,r1,r2,旋转,100,strokeColour,strokeWeight,StrokeCapacity,FillColor,fillOpacity,选项)
}
google.maps.Polygon.Shape=函数(点、r1、r2、r3、r4、旋转、顶点计数、strokeColour、strokeWeight、StrokeCapity、FillColor、fillOpacity、选项、倾斜){
var rot=-rotation*Math.PI/180;
var点=[];
var latConv=google.maps.geometry.sphereal.ComputedIstanceBeween(point,新的google.maps.LatLng(point.lat()+0.1,point.lng())*10;
var lngConv=google.maps.geometry.sphereal.ComputedDistanceBeween(point,new google.maps.LatLng(point.lat(),point.lng()+0.1))*10;
var阶跃=(360/顶点计数)| 10;
var-flop=-1;
如果(倾斜){
var I1=180/垂直计数;
}否则{
var I1=0;
}

对于(var i=I1;i您必须自己计算路径。这应该会有帮助:

编辑:这可能更有用:

的v3端口支持椭圆(但不基于边界)

大小与地图边界一致

代码片段:

var-map=null;
变量myOptions={
缩放:8,
中心:新google.maps.LatLng(43,-79.5),
mapTypeControl:true,
mapTypeControlOptions:{
样式:google.maps.MapTypeControlStyle.DROPDOWN_菜单
},
导航控制:对,
mapTypeId:google.maps.mapTypeId.ROADMAP
}
map=new google.maps.map(document.getElementById(“map”),
肌肽);
google.maps.event.addListenerOnce(映射,“边界更改”,函数(){
var bounds=map.getBounds();
var major_axis=google.maps.geometry.sphereal.ComputedIstanceBeween(bounds.getNorthEast(),new google.maps.LatLng(bounds.getSouthWest().lat(),bounds.getNorthEast().lng())/2;
var minor_axis=google.maps.geometry.spheremic.ComputedDistanceBetween(
新的google.maps.LatLng(bounds.getCenter().lat(),bounds.getsoutwest().lng()),
新的google.maps.LatLng(bounds.getCenter().lat(),bounds.getNorthEast().lng())/2;
//==椭圆===
var point=map.getCenter();//新建google.maps.LatLng(43,-78);
var椭圆=google.maps.Polygon.ellipse(点,长轴,短轴,0,“#000000”,2,1,“#ffff00”,0.5);
椭圆.setMap(map);
});
//此Javascript基于
//社区教会Javascript团队
// http://www.bisphamchurch.org.uk/   
// http://econym.org.uk/gmap/
//EShapes.js
//
//基于“thetoy”的一个想法和几行代码
//
//此Javascript由Mike Williams提供
//社区教会Javascript团队
//   http://www.bisphamchurch.org.uk/   
//   http://econym.org.uk/gmap/
//
//本作品根据知识共享许可证获得许可
//   http://creativecommons.org/licenses/by/2.0/uk/
//
//版本0.0 04/Apr/2008尚未完成
//版本1.0 2008年4月10日首次发布
//Lawrence Ross于2011年10月12日将版本3.0移植到v3
google.maps.Polygon.Ellipse=函数(点、r1、r2、旋转、strokeColour、strokeWeight、StrokeCapacity、FillColor、fillOpacity、opts){
旋转=旋转| | 0;
返回google.maps.Polygon.Shape(点,r1,r2,r1,r2,旋转,100,strokeColour,strokeWeight,StrokeCapacity,FillColor,fillOpacity,选项)
}
google.maps.Polygon.Shape=函数(点、r1、r2、r3、r4、旋转、顶点计数、strokeColour、strokeWeight、StrokeCapity、FillColor、fillOpacity、选项、倾斜){
var rot=-rotation*Math.PI/180;
var点=[];
var latConv=google.maps.geometry.sphere