Javascript Ionic推送到数组时,会给出[object]

Javascript Ionic推送到数组时,会给出[object],javascript,arrays,google-maps,typescript,ionic-framework,Javascript,Arrays,Google Maps,Typescript,Ionic Framework,得到了这个函数 drawCircle(pointa, pointb, radius, dir) { console.log("TESTING POINTA POINTB >>>>>>>>>>>>"+pointa+" - "+pointb); let lat; let lng; var d2r = Math.PI / 180; // degrees to radians var

得到了这个函数

drawCircle(pointa, pointb, radius, dir) { 
    console.log("TESTING POINTA POINTB >>>>>>>>>>>>"+pointa+" - "+pointb);
    let lat;
    let lng;
    var d2r = Math.PI / 180;   // degrees to radians 
    var r2d = 180 / Math.PI;   // radians to degrees 
    var earthsradius = 3963; // 3963 is the radius of the earth in miles or 6371 in km
    var points = 32; 

    // find the raidus in lat/lon 
    var rlat = (radius / earthsradius) * r2d; 
    var rlng = rlat / Math.cos(pointa * d2r); 

    var extp = new Array(); 
    if (dir==1)   {var start=0;var end=points+1} // one extra here makes sure we connect the ends
    else      {var start=points+1;var end=0}
    for (var i=start; (dir==1 ? i < end : i > end); i=i+dir) { 

      var theta = Math.PI * (i / (points/2)); 
      let ey = pointb + (rlng * Math.cos(theta)); // center a + radius x * cos(theta) 
      let ex = pointa + (rlat * Math.sin(theta)); // center b + radius y * sin(theta) 
      extp.push({lat: ey, lng: ex}); 
      //console.log("PUSHING TO EXTP >>>>>>>>>>>>",{'lat': ey,'lng': ex});

    } 
    console.log("CHECK EXTP ARRAY >>>>>>>>>>>>",extp);
    return extp;
  }
但是,在控制台中,我没有给出值,而是得到了对象,而不是(例如):{lat:85,lng:179.9}这种格式,作为回报,它不会在多边形中构建孔

选中EXTP数组>>>>>>>>>>>>>>>>>>>>>>>>[对象对象],[对象对象对象],[对象对象对象],[对象对象对象],[对象对象对象],[对象对象对象对象],[对象对象对象对象对象],[对象对象对象对象],[对象对象对象对象对象对象对象对象对象对象],[对象对象对象对象对象对象对象对象对象对象],[对象对象对象对象对象对象对象对象],[对象对象],[对象对象],[对象对象],[对象对象对象],[对象对象],[对象对象对象],[对象对象对象],[对象对象对象],[对象对象],[对象对象对象],[对象对象对象],[对象对象对象对象],[对象对象对象对象]

编辑:

如果我替换

this.map.addPolygon({
                points: this.points,
                  holes: this.drawCircle(this.myLat, this.myLong, 1, 1),
                    'strokeColor': "black",
                    'strokeWidth': 2,
                    'fillColor': "#222222"
                  });


它工作正常,所以我认为问题仍然是由于extp。有什么想法吗?

当您调用console.log时,一些浏览器使用
将对象转换为字符串
,因此您的属性可能在那里。您使用的浏览器是什么?您可以通过打印
extp[0]的类型来确认数组对象的类型吗
并检查第一个对象是否具有extp[0]的属性类型……检查extp类型的>>>>>>>>>>>>>>>>>>>对象,以及如何记录
extp[0]。lat
对象。getOwnPropertyNames(extp[0])
Doing console.dir(extp[0])显示{“lat 55.12345678,“lng”:25.12345678}但代码在其他方面是有效的?这是控制台问题还是其他问题?
this.map.addPolygon({
                points: this.points,
                  holes: this.drawCircle(this.myLat, this.myLong, 1, 1),
                    'strokeColor': "black",
                    'strokeWidth': 2,
                    'fillColor': "#222222"
                  });
this.map.addPolygon({
                points: this.points,
                  holes: [
                    [
                        {lat: 29.68224948021748,lng: -23.676965750000022},  
                        {lat: 29.68224948021748,lng: 44.87772174999998}, 
                        {lat: 71.82725578445813,lng: 44.87772174999998}, 
                        {lat: 71.82725578445813,lng: -23.676965750000022}, 

                      ]
                    ],
                    'strokeColor': "black",
                    'strokeWidth': 2,
                    'fillColor': "#222222"
                  });