Javascript 传递中心的有效lat/lng时,Google地图与圆圈错误

Javascript 传递中心的有效lat/lng时,Google地图与圆圈错误,javascript,google-maps,Javascript,Google Maps,我得到一个关于lat不是有效值的错误-当我将“中心”传递给标记时,它工作正常,它是地图的中心,唯一不工作的是圆 错误: InvalidValueError:索引0处:索引0处:不是具有有限坐标的LatLng或Latlngileral:在属性中lat:NaN不是可接受的值 守则: //eslint禁用下一行no undef this.$data.myMap=new google.maps.Map(mapDiv作为HTMLElement{ 中间:{lat:this.$props.circle.lat

我得到一个关于lat不是有效值的错误-当我将“中心”传递给
标记时,它工作正常,它是地图的中心,唯一不工作的是

错误:

InvalidValueError:索引0处:索引0处:不是具有有限坐标的LatLng或Latlngileral:在属性中lat:NaN不是可接受的值

守则:

//eslint禁用下一行no undef
this.$data.myMap=new google.maps.Map(mapDiv作为HTMLElement{
中间:{lat:this.$props.circle.lat,lng:this.$props.circle.lng},
缩放:12,
});
const center={lat:this.$data.myMap.center.lat(),lng:this.$data.myMap.center.lng()};
控制台日志('Center',Center);
//eslint禁用下一行无未定义
const marker=new google.maps.marker({
位置:中,
map:this.$data.myMap,
});
//eslint禁用下一行无未定义
这是。$data.myCircle=new google.maps.Circle({
strokeColor:“#FF0000”,
笔划不透明度:0.8,
冲程重量:2,
填充颜色:'#FF0000',
不透明度:0.35,
map:this.$data.myMap,
居中
半径:这个。$props.circle.radius*100,
});
console.log消息:

Center {lat: 37.7674915, lng: -122.4450328}

js?key=...&libraries=places&v=weekly:78 InvalidValueError: at index 0: at index 0: not a LatLng or LatLngLiteral with finite coordinates: in property lat: NaN is not an accepted value
...
正如你所看到的,唯一的错误是当我们创建圆时-地图以正确的中心绘制,并且放置了标记。这里的交易是什么

编辑:

即使我在硬代码中心遇到了相同的错误-这不起作用:

this.$data.myCircle = new google.maps.Circle({
      strokeColor: '#FF0000',
      strokeOpacity: 0.8,
      strokeWeight: 2,
      fillColor: '#FF0000',
      fillOpacity: 0.35,
      map: this.$data.myMap,
      center: { lat: 37.7674915, lng: -122.4450328 },
      radius: this.$props.circle.radius * 100,
    });
这也不起作用:

this.$data.myCircle = new google.maps.Circle({
      strokeColor: '#FF0000',
      strokeOpacity: 0.8,
      strokeWeight: 2,
      fillColor: '#FF0000',
      fillOpacity: 0.35,
      map: this.$data.myMap,
      // eslint-disable-next-line no-undef
      center: new google.maps.LatLng(37.7674915, -122.4450328),
      radius: this.$props.circle.radius * 100,
    });
在这里,您可以看到地图和标记正常工作:


因此,错误消息就是错误所在


误差在于半径,而不是圆的
中心。出现此错误的任何人都要确保检查半径以及圆的lat/lng属性。

您能提供一个示例来说明错误吗?您问题的第一段代码中有一个明显的语法错误(
center,
应该是
center:center,
)。@geocodezip-这不是打字错误-这是有效的ES6语法。。。代码都是正在传输的有效ES6。@geocodezip-这是来自Google的错误消息,真正的问题是
radius