我有一个种子应用程序,其中包含两个自定义元素,一个具有自定义Google Maps地图元素,另一个具有街景视图:
**seed-app.html**
<ims-map map-options='{"zoom":"18", "lat":"42.59615", "lng":"-76.151958"}'> //implements a Google Maps map
</ims-map>
<div id="sideBar">
<street-view-card id="streetViewCard"></street-view-card>
</div>
第二个元素中包含街景视图:
**street-view-card.js**
_addStreetView() {
this.panorama = new google.maps.StreetViewPanorama(this.container, {
position: {lat: 45.59715, lng: -78.151858},
pov: {heading: 180, pitch: 0}
});
}
用户可以在第一个地图上单击自定义元素。单击将导致坐标存储在features
变量中。单击将关闭功能_handleFeatureSelected
。我想将此函数中的坐标传递到街景卡。我正在尝试的是:
**seed-app.js**
_handleFeatureSelected(event) {
const {feature} = event.detail;
this.streetViewCard = document.getElementById("streetViewCard"); //this works, I get the element as expected
this.streetViewCard.panorama.setPosition(feature.geometry.coordinates) //here feature.geometry.coordinates contains [42.345573, -71.098326] for example. This doesn't work anymore.
}
我确实找到了this,但是,这不是与Polymer一起使用的,我也不想使用街景小雕像,只是想从features
变量中获取坐标。