📌  相关文章
📜  如何从角度 6 中的地址获取纬度和经度 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:47.705000             🧑  作者: Mango

代码示例1
getGeoLocation(address: string): Observable {
    console.log('Getting address: ', address);
    let geocoder = new google.maps.Geocode();
    return Observable.create(observer => {
        geocoder.geocode({
            'address': address
        }, (results, status) => {
            if (status == google.maps.GeocoderStatus.OK) {
                observer.next(results[0].geometry.location);
                observer.complete();
            } else {
                console.log('Error: ', results, ' & Status: ', status);
                observer.error();
            }
        });
    });
}