我们可以Object.prototype.toString.call(foo)
用来检测对象类(foo的类型),它运行良好.
但为什么Object.toString.call({})
扔TypeError: Function.prototype.toString is not generic
?
不Object.toString
继承Object.prototype
吗?
我正在一个页面中实现一个谷歌地图,其中一个地方ID传递给我,然后我需要获得这样的地方ID并加载该标记的地图.我正在浏览文档,但不清楚如何从<agm-map>
标记中定位地图对象,以便我可以设置地点ID.以下是代码的一部分:
public latitude: number;
public longitude: number;
public zoom: number;
public placeid: string;
constructor(
private mapsAPILoader: MapsAPILoader,
private ngZone: NgZone
) {}
ngOnInit() {
//set google maps defaults
this.zoom = 4;
this.latitude = 39.8282;
this.longitude = -98.5795;
this.placeid = "ChIJMS2FahDQzRIRcJqX_aUZCAQ";
//set current position
this.setCurrentPosition();
this.mapsAPILoader.load().then(() => {
//How do i set the agm-map here to load the map with the placeid
});
}
private setCurrentPosition() {
if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition((position) => {
this.latitude = position.coords.latitude;
this.longitude …
Run Code Online (Sandbox Code Playgroud)