Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何从字符串中获取LatLng对象?_Angular_Typescript - Fatal编程技术网

Angular 如何从字符串中获取LatLng对象?

Angular 如何从字符串中获取LatLng对象?,angular,typescript,Angular,Typescript,我在Angular项目中使用Google Places library和Google Places都要求location params是LatLng对象,但我只有作为字符串的坐标,所以问题是: 如何将LatLng对象中的字符串“44.7179422,10.5465457”转换为作为参数传递?我尝试使用just.split','您可以继续使用.split函数,但还需要将字符串转换为数字 const arr = str.split(','); this.latLng = new google.map

我在Angular项目中使用Google Places

library和Google Places都要求location params是LatLng对象,但我只有作为字符串的坐标,所以问题是:

如何将LatLng对象中的字符串“44.7179422,10.5465457”转换为作为参数传递?我尝试使用just.split','

您可以继续使用.split函数,但还需要将字符串转换为数字

const arr = str.split(',');
this.latLng = new google.maps.LatLng(Number(arr[0]), Number(arr[1]));
下面是一个关于转换时可能有用的不同检查的示例