AGM PolyGon-Firestore GeoPoint-InvalidValueError:索引为0:不是LatLng或LatLngLiteral:在属性lat中:不是数字

时间:2019-01-18 01:47:24

标签: firebase google-maps google-cloud-firestore angular-google-maps

使用AGM PolyGonFirestore Geopoint在Google地图上构造多边形。

使用AGM中的[路径],解析一系列的地理位置。

@Input() paths: Array<LatLng|LatLngLiteral>|Array<Array<LatLng|LatLngLiteral>> = [];

firestore中的数据是一个Geopoints数组,其返回为:

[
{ "_lat": -20.2322, "_long": 120.2342 },
{ "_lat": -20.3322, "_long": 120.3342 },
{ "_lat": -21.3322, "_long": 120.3342 },
]

返回错误:

Error: Uncaught (in promise): InvalidValueError: at index 0: not a LatLng or 
LatLngLiteral: in property lat: not a number

为什么当它明显是数字时会抛出错误“不是数字”?

1 个答案:

答案 0 :(得分:0)

它期望Array<Array<LatLng|LatLngLiteral>>-这是一个对象数组。例如:

[
    new google.maps.LatLng(-20.2322, 120.2342),
    new google.maps.LatLng(-20.2322, 120.2342),
    new google.maps.LatLng(-20.2322, 120.2342)
]