img在Angular2中设置标记的最佳方法是什么?
这不起作用(而不是因为键):
<img src="//maps.googleapis.com/maps/api/streetview?size=400x400&location="{{property.lat}}, {{property.long}}"key=aiwefmboij234blahblah" />
Run Code Online (Sandbox Code Playgroud)
我们如何将lat/long值传入src属性?
谢谢!
我有一个 TypeScript 中的 Google 地理编码服务。我需要此方法在获取给定地址的纬度/经度后返回“GoogleMap”类。
我创建了一个返回“GoogleMap”类型的 TypeScript 方法。但是,我得到了一个
既不是 void 也不是 any 的函数必须返回一个值...
这是我的方法:
getLatLongFromAddress(streetAddress: string): GoogleMap {
this.geoCodeURL = GOOGLE_GEOCODE_BASE_URL + streetAddress +
"&key=" + GOOGLE_MAPS_API_KEY;
this.googleMap = new GoogleMap();
this.httpService
.get(this.geoCodeURL)
.subscribe((data) => {
this.googleMap.lat = data.results.geometry.location.lat;
this.googleMap.long = data.results.geometry.location.lng;
return this.googleMap;
},
(error) => {
console.error(this.geoCodeURL + ". " + error);
return Observable.throw("System encountered an error: " + error);
},
() => {
console.info("ok: " + this.geoCodeURL);
return this.googleMap;
});
}
Run Code Online (Sandbox Code Playgroud)
我可以理解 http 调用将是异步的,并且流程应该继续到方法的底部,可能在响应返回数据之前。要返回“GoogleMap”,我需要等待这个 Observable 吗?我该怎么做呢?
谢谢! …