我在 Ionic 应用程序中使用本地地理编码器。记录在这里
这是我的提供者中的方法 -
//This calls the Native geocoder and returns the geocoordinates.
getGeoCode(address: string): Promise<any> {
console.log('The address key is - ' + address);
return new Promise((resolve, reject) => {
this.nativeGeocoder.forwardGeocode(address)
.then((nativegeocoordinates: NativeGeocoderForwardResult) => {
console.log('The coordinates are - ' + JSON.stringify(nativegeocoordinates));
let addressCoordinates: DeliveryAddressCoordinates = nativegeocoordinates;
resolve(addressCoordinates);
})
.catch((error: any) => {
console.log(JSON.stringify(error));
reject(error);
});
})
}
该方法接受地址字符串作为输入。所以我从 google places API 获取地址,并在此处传递描述。
现在,对于某些地址,它似乎找不到坐标,并返回“找不到位置”消息。例如,“Bhadra Brookefields Apartment B Block, Kundanahalli Lake Road, Kundalahalli, Brookefield, Bengaluru, Karnataka, India”是一个有效地址并返回坐标,而“Times Square 42 Street Station, New York, NY, USA”没有找到匹配并返回一条消息 - “找不到位置”。
有关更多信息,“找不到位置”似乎源自第 182 行的 cordova 插件代码。,它在哪里引用 Android 类。
这是一个已知的问题?还是我做错了什么?